map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do |m|
m.resources :requests, :controller => "admin/requests" do |req|
req.resources :histories
end
end
When I do this :
map.with_options :path_prefix => “/admin”, :name_prefix => “admin_” do |m|
m.resources :requests, :controller => “admin/requests” do |request|
request.resources :histories
end
end
And in my view I do this :
<%= admin_histories_url %>
I get this error :
undefined local variable or method `admin_histories_url’
So I’ve changed to that :
map.with_options :path_prefix => “/admin”, :name_prefix => “admin_” do |m|
m.resources :histories, :controller => “admin/histories”
m.resources :requests, :controller => “admin/requests” do |request|
request.resources :histories
end
end
It seems to work with this in my route.rb :
map.with_options :path_prefix => “/admin”, :name_prefix => “admin_” do |m|
m.resources :requests, :controller => “admin/requests” do |request|
request.resources :histories, :path_prefix => "/admin/requests/:request_id", :name_prefix => "admin_"
end
end
If I try that in my view :
<%= admin_histories_url(@request) %>
Yes, that’s it.
But there is still an error in my solution.
Here is the final (I hope) solution :
map.with_options :path_prefix => “/admin”, :name_prefix => “admin_” do |m|
m.resources :requests, :controller => “admin/requests” do |request|
request.resources :histories, :path_prefix => “/admin/requests/:request_id”, :name_prefix => “admin_”, :controller => “admin/histories”
end
end
In my previous solution, I forgot ":controller => “admin/histories”.
Thanks for your help.
Everybody is still welcome to comment this solution.
Thomas.
I ran across this the other day and was confused about why the with_options options don’t trickle down but I guess it doesn’t actually matter why since they don’t.