views:

11

answers:

2

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.

+1  A: 

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
marcgg
+2  A: 

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.

makevoid