Hello-
I’m giving RESTful development a shot. I’m running into some difficulty
with controller I have grouped into modules. Specifically, I have a
“admin” module with a “user” controller (created with “generate
controller admin/user”). I managed to get map.resources wired up with
this code:
map.resources Admin::User, :path_prefix => “/admin”
I’m not sure if that’s the right way, but it seems to work. The problem
I’m running into is with setting up my link_tos. I tried this code:
<%= link_to ‘Show’, user_path(@user) %>
Which failed with a “undefined method `user_path’ for
#<#Class:0x47eaa14:0x47ea9ec>”. Not unexpected. However I can’t figure
out the right syntax for the path to my user admin actions. Can anyone
help?
Regards-
Eric
Look at namespace
map.namespace :admin do |admin|
admin.resources :users
end
gives you helpers such as this:
<%= link_to ‘Show’, admin_user_path(@user) %>
also look at the very useful:
rake routes
Eric M. wrote:
Hello-
I’m giving RESTful development a shot. I’m running into some difficulty
with controller I have grouped into modules. Specifically, I have a
“admin” module with a “user” controller (created with “generate
controller admin/user”). I managed to get map.resources wired up with
this code:
map.resources Admin::User, :path_prefix => “/admin”
I’m not sure if that’s the right way, but it seems to work. The problem
I’m running into is with setting up my link_tos. I tried this code:
<%= link_to ‘Show’, user_path(@user) %>
Which failed with a “undefined method `user_path’ for
#<#Class:0x47eaa14:0x47ea9ec>”. Not unexpected. However I can’t figure
out the right syntax for the path to my user admin actions. Can anyone
help?
Regards-
Eric
map.namespace :admin do
map.resources :users
end
admin_user_path(@user)
should do the trick.
On Jan 29, 2008 5:35 PM, Eric M.
[email protected]
wrote:
Regards-
Eric
Posted via http://www.ruby-forum.com/.
–
Ryan B.
Feel free to add me to MSN and/or GTalk as this email.
This is great info. Exactly what I waslooking for. Thanks.
Regards-
Eric
Hi,
Here is a perfect 2.0 RESTful nested and namespace tutorial, after
checking u would totally understand the whole stuff. I am not doing ad
here. cuz it really needs to recommend
On 1ÔÂ29ÈÕ, ÉÏÎç9ʱ05·Ö, Eric M. [email protected]