Thomas Balthazar
2007-Feb-07 09:44 UTC
Upgrade to Rails 1.2.2 : RESTful routes not working anymore
Hello,
I just upgraded my app to Rails 1.2.2.
My routes are :
map.with_options :path_prefix => "/admin", :name_prefix =>
"admin_" do |m|
m.resources :requests, :controller => "admin/requests",
:collection => {
:destroy => :delete, :search => :post } do |request|
request.resources :histories, :path_prefix =>
"/admin/requests/:request_id", :name_prefix => "admin_",
:controller =>
"admin/histories"
end
end
I got this error :
admin_destroy_requests_url failed to generate from
{:action=>"destroy",
:controller=>"admin/requests"}, expected:
{:action=>"destroy",
:id=>/[^\/;.,?]+/, :controller=>"admin/requests"}, diff:
{:id=>/[^\/;.,?]+/}
From this piece of code
<% form_for(:request, :url => admin_destroy_requests_path, :html => {
:method => :delete, :id => :adminDeleteForm, :name => :adminDeleteForm
}) do
|f| %>
If I switch my app back to 1.2.1, everything works fine.
Any idea?
Thanks in advance,
Thomas.
On 2/2/07, Thomas Balthazar
<thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> 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.
>
> On 2/2/07, Ed Hickey
<bassnode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> >
> >
> > so if you do this:
> > <%= admin_histories_url(@request) %>
> >
> > you should get something like:
> > "/admin/requests/1/histories"
> >
> > if you do this:
> > <%= admin_histories_url(@request, @history) %>
> >
> > you should get something like:
> > "/admin/requests/1/histories/2"
> >
> >
> > You have achieved what you requested in your original email, no?
> >
> > ed
> >
> > On 2/2/07, Thomas Balthazar <
thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > > 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) %><br />
> > >
> > > I now get this :
> > > http://0.0.0.0:3000/admin/requests/24/histories
> > >
> > > If anybody wants to comment this solution, he is more than
welcome.
> > > I''m not sure to do the right thing here.
> > >
> > > Thanks,
> > > Thomas.
> > >
> > >
> > >
> > >
> > > On 2/2/07, Thomas Balthazar
<thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > > > Hello Ed,
> > > > Thanks for your answer.
> > > >
> > > > 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
> > > >
> > > > And now : <%= admin_histories_url %> give me this :
> > > http://0.0.0.0:3000/admin/histories
> > > >
> > > > If I try this in my view :
> > > > <%= admin_histories_url(@request) %>
> > > >
> > > > I get this error :
> > > > You have a nil object when you didn''t expect it!
> > > > The error occurred while evaluating nil.to_sym
> > > >
> > > > So I don''t think it solves the problem.
> > > > Any idea?
> > > > Thanks,
> > > > Thomas.
> > > >
> > > >
> > > >
> > > > On 2/2/07, Ed Hickey <
bassnode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > > > >
> > > > > try this:
> > > > >
> > > > > map.with_options :path_prefix => "/admin",
:name_prefix =>
> > "admin_" do
> > > |m|
> > > > > m.resources :requests, :controller =>
"admin/requests" do |req|
> > > > > req.resources :histories
> > > > > end
> > > > > end
> > > > >
> > > > >
> > > > > ed
> > > > >
> > > > >
> > > > > On 2/2/07, Thomas Balthazar <
thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > > > > > Hello,
> > > > > >
> > > > > > I''m now playing with REST and Rails (with
Rails 1.2.1).
> > > > > >
> > > > > > I have the following routes in my route.rb :
> > > > > >
> > > > > > map.with_options :path_prefix =>
"/admin", :name_prefix =>
> > "admin_" do
> > > |m|
> > > > > > m.resources :requests, :controller =>
"admin/requests"
> > > > > > end
> > > > > >
> > > > > > This give me a RESTful /admin/requests controller.
> > > > > >
> > > > > > In my application, a Request has many Histories.
> > > > > > How can I add the correct route to have something
like that :
> > > > > > /admin/requests/24/histories.
> > > > > >
> > > > > > Without the /admin, it would simply look like this
:
> > > > > > map.resources :requests do |request|
> > > > > > request.resources :histories
> > > > > > end
> > > > > >
> > > > > > But with the /admin, everything becomes to be
confused for me.
> > > > > > Any help would be greatly appreciated.
> > > > > >
> > > > > > Thanks in advance,
> > > > > > Thomas.
> > > > > >
> > > > > >
> > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > > >
> > >
> >
> >
> > --
> > Ed Hickey
> > Developer
> > Litmus Media
> > 816-533-0409
> > ehickey-A4HEbNdjHgMmlAP/+Wk3EA@public.gmane.org
> > A Member of Think Partnership, Inc
> > www.ThinkPartnership.com
> > Amex ticker symbol: THK
> >
> > > >
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thijs Cadier
2007-Feb-07 10:17 UTC
Re: Upgrade to Rails 1.2.2 : RESTful routes not working anymore
I''ve seen the exact same error, looks like a regression in Rails --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thomas Balthazar
2007-Feb-07 14:31 UTC
Re: Upgrade to Rails 1.2.2 : RESTful routes not working anymore
Rick Olson gave me the solution. #destroy is a reserved word. I changed to trash. Works like a charm. Happy again ;o) Thomas; On 2/7/07, Thijs Cadier <thijs-TzImxERFPcysTnJN9+BGXg@public.gmane.org> wrote:> > > I''ve seen the exact same error, looks like a regression in Rails > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ed Hickey
2007-Feb-07 15:52 UTC
Re: Upgrade to Rails 1.2.2 : RESTful routes not working anymore
ah hah! makes sense. ed On 2/7/07, Thomas Balthazar <thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Rick Olson gave me the solution. > #destroy is a reserved word. > I changed to trash. > Works like a charm. > Happy again ;o) > Thomas; > > On 2/7/07, Thijs Cadier <thijs-TzImxERFPcysTnJN9+BGXg@public.gmane.org> wrote: > > > > > > I''ve seen the exact same error, looks like a regression in Rails > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---