I am doing the following: link_to "delete my avatar", user_pictures_path(:user_id => @user, :id => @ user.pictures.last), :method => :delete and it is creating the following link: http://127.0.0.1:3000/users/4/pictures?id=10 Two things: 1) shouldn''t it create the following URL? http://127.0.0.1:3000/users/4/pictures/10 i.e. not the ?id=10 but just /10? 2) Is there a cleaner way of building the url? Thanks :-) -- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org Blog: http://www.kopanas.com Conference: http://www.cusec.net Twits: http://www.twitter.com/kopanas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
If you are using nested routes like this: map.resources :users do |user| user.resources :pictures end Then you should be able to do this: link_to "delete my avatar", user_pictures_path(@user, @user.pictures.last), :method => :delete Michael Bleigh michael-+08J6pdAJjhWk0Htik3J/w@public.gmane.org On Dec 13, 2007, at 9:58 PM, John Kopanas wrote:> I am doing the following: > > link_to "delete my avatar", user_pictures_path(:user_id => > @user, :id => @user.pictures.last), :method => :delete > > and it is creating the following link: > > http://127.0.0.1:3000/users/4/pictures?id=10 > > Two things: > 1) shouldn''t it create the following URL? > http://127.0.0.1:3000/users/4/pictures/10 > > i.e. not the ?id=10 but just /10? > > 2) Is there a cleaner way of building the url? > > Thanks :-) > > -- > John Kopanas > john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org > > Blog: http://www.kopanas.com > Conference: http://www.cusec.net > Twits: http://www.twitter.com/kopanas > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
When I do that I get the following error: undefined method `has_key?'' for #<Picture:0x266d170> when I do it my way I do not get an error but the id of the picture gets passed in querystring instead of URL... any suggestions peeps? On Dec 13, 2007 10:33 PM, Michael Bleigh <mbleigh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If you are using nested routes like this: > map.resources :users do |user| > user.resources :pictures > end > > Then you should be able to do this: > > link_to "delete my avatar", user_pictures_path(@user, @user.pictures.last), > :method => :delete > > Michael Bleigh > michael-+08J6pdAJjhWk0Htik3J/w@public.gmane.org > > On Dec 13, 2007, at 9:58 PM, John Kopanas wrote: > > I am doing the following: > link_to "delete my avatar", user_pictures_path(:user_id => @user, :id => @ > user.pictures.last), :method => :delete > > and it is creating the following link: > > http://127.0.0.1:3000/users/4/pictures?id=10 > > Two things: > 1) shouldn''t it create the following URL? > http://127.0.0.1:3000/users/4/pictures/10 > > i.e. not the ?id=10 but just /10? > > 2) Is there a cleaner way of building the url? > > Thanks :-) > > -- > John Kopanas > john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org > > Blog: http://www.kopanas.com > Conference: http://www.cusec.net > Twits: http://www.twitter.com/kopanas > > > > > > > >-- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org Blog: http://www.kopanas.com Conference: http://www.cusec.net Twits: http://www.twitter.com/kopanas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I think you want this instead user_picture_path(@user, @user.pictures.last) <== Note: singular form of ''picture'' in the method name. On Dec 13, 8:00 pm, "John Kopanas" <kopa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> When I do that I get the following error: > > undefined method `has_key?'' for #<Picture:0x266d170> > > when I do it my way I do not get an error but the id of the picture gets > passed in querystring instead of URL... any suggestions peeps? > > On Dec 13, 2007 10:33 PM, Michael Bleigh <mble...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > If you are using nested routes like this: > > map.resources :users do |user| > > user.resources :pictures > > end > > > Then you should be able to do this: > > > link_to "delete my avatar", user_pictures_path(@user, @user.pictures.last), > > :method => :delete > > > Michael Bleigh > > mich...-+08J6pdAJjhWk0Htik3J/w@public.gmane.org > > > On Dec 13, 2007, at 9:58 PM, John Kopanas wrote: > > > I am doing the following: > > link_to "delete my avatar", user_pictures_path(:user_id => @user, :id => @ > > user.pictures.last), :method => :delete > > > and it is creating the following link: > > >http://127.0.0.1:3000/users/4/pictures?id=10 > > > Two things: > > 1) shouldn''t it create the following URL? > >http://127.0.0.1:3000/users/4/pictures/10 > > > i.e. not the ?id=10 but just /10? > > > 2) Is there a cleaner way of building the url? > > > Thanks :-) > > > -- > > John Kopanas > > j...-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org > > > Blog:http://www.kopanas.com > > Conference:http://www.cusec.net > > Twits:http://www.twitter.com/kopanas > > -- > John Kopanas > j...-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org > > Blog:http://www.kopanas.com > Conference:http://www.cusec.net > Twits:http://www.twitter.com/kopanas--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---