Reputation: 30578
I found that I only can @products in the views/products/ folder, I can't call the @products in other position, like views/store ..... .... If I want to use the @products in the view/store, wt should I do? apart from calling /views/products.
Upvotes: 0
Views: 31
Reputation: 3287
Well, the @products you get in the views is actually defined in your controllers actions (ProductsController /controllers/products_controller.rb) you have to define @products in an action of your 'SecondController'
you can start by first looking at the index or show actions of ProductsController, and check some tutorials or books.
Upvotes: 2
Reputation: 66445
You need to define it in the action you're using
If you want to use it in /store/an_action, add in the controller :
def an_action
@products = Product.all # for instance
end
Upvotes: 1