torso
(torso)
June 30, 2008, 7:46am
1
Hi!
I have made an scaffold for Item table like script/generate scaffold
Item. Everything went fine, but now i like to add list action to
controller
Def list
$items = Item.finde(:all)
end
I have added it, but how i can see the template like http://address/items/list
Can i redirect it some how?
Action index does same thing as list action,but i want to make
different kind of view for those.
11175
(-- --)
June 30, 2008, 9:42am
2
torso wrote:
Hi!
I have made an scaffold for Item table like script/generate scaffold
Item. Everything went fine, but now i like to add list action to
controller
Def list
$items = Item.finde(:all)
end
I have added it, but how i can see the template like
http://address/items/list
Can i redirect it some how?
Action index does same thing as list action,but i want to make
different kind of view for those.
I think you did not declare it in your rooting file.
Try to add/update something like that :
map.resources :items,
:collection => {
:list => :get
}
Hope this helps.
Guillaume Petit
http://www.nomadsper.com
torso
(torso)
June 30, 2008, 10:10am
3
So i have to add it to the routers.rb in config directory. Am i
right?
radar
(Ryan Bigg)
June 30, 2008, 12:42pm
5
I would be more concerned with the fact he’s defining $items in his action…
The $ signifies a global variable, which I personally have never found a use for. Change the $ to a @ to make it an instance variable so the variable is only defined for that instance.