H guys, first of all let me tell u I am new to spree, so my question might sound stupid to most of you. I want to customize for example the "index" method in the home_controller.rb, I know the right way is to use a decorators. So I have created this file app/controller/home_controller_decorator.rb. I have in there
# app/controller/home_controller_decorator.rb
HomeController.class_eval do
def index
# Empty method
end
end
The original spree index method looks like
def index
@searcher = Spree::Config.searcher_class.new(params)
@products = @searcher.retrieve_products
respond_with(@products)
end
I expect that when I restart the server with the _decorator added it will display me no products on the home page, or will crash. When applying this decorator and starting the server I get this message
agop@linux-as2q:~/Desktop/spp> rails server -p 3000
/home/agop/Desktop/spp/app/controllers/home_controller_decorator.rb:1:in `<top (required)>': uninitialized constant Spree::BaseController (NameError)
from /home/agop/Desktop/spp/lib/spree_site.rb:5:in `block in <class:Engine>'
from /home/agop/Desktop/spp/lib/spree_site.rb:4:in `glob'
from /home/agop/Desktop/spp/lib/spree_site.rb:4:in `<class:Engine>'
from /home/agop/Desktop/spp/lib/spree_site.rb:2:in `<module:SpreeSite>'
from /home/agop/Desktop/spp/lib/spree_site.rb:1:in `<top (required)>'
from /home/agop/Desktop/spp/config/application.rb:11:in `<class:Application>'
from /home/agop/Desktop/spp/config/application.rb:10:in `<module:Spp>'
from /home/agop/Desktop/spp/config/application.rb:9:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:28:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:28:in `block in <top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I am probably not writing the decorator in the way spree expects. What is the correct way to apply this decorator on the home_controller.rb index method?