Hi, I have this link_to helper <%= link_to "edit", :action => ''edit'', :id => @pirate, :confirm => ''should edit?'' %> It should (in order to what I read in apidock) prompt me for confirmation via javascript confirm, but it doesn''t. Any idea why? Also when I set the :id attribute, either @pirate or @pirate.id work... why is that, and what''s the preferred form? Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Dec 30, 8:59 pm, Pablo Fernandez <fernandezpabl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, I have this link_to helper > > <%= link_to "edit", :action => ''edit'', :id => @pirate, :confirm => > ''should edit?'' %> > > It should (in order to what I read in apidock) prompt me for > confirmation via javascript confirm, but it doesn''t. >If you check the html generated you''ll noticed that the url has a confirm parameter. If you check apidoc again you''ll see that the confirm option needs to be passed in the second options hash, ie link_to ''blah'', {options for url}, {other stuff here}> Any idea why? > > Also when I set the :id attribute, either @pirate or @pirate.id > work... why is that, and what''s the preferred form? >Because if you pass an activerecord object as the :id for a url rails calls to_param on it, which by default returns id. The preferred form these days would be to have the appropriate routes and do link_to ''edit'', edit_pirate_path(@pirate) Fred> Thanks!--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks so much, I was passing the args in the wrong order as you stated. On Tue, Dec 30, 2008 at 7:36 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Dec 30, 8:59 pm, Pablo Fernandez <fernandezpabl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> Hi, I have this link_to helper >> >> <%= link_to "edit", :action => ''edit'', :id => @pirate, :confirm => >> ''should edit?'' %> >> >> It should (in order to what I read in apidock) prompt me for >> confirmation via javascript confirm, but it doesn''t. >> > If you check the html generated you''ll noticed that the url has a > confirm parameter. If you check apidoc again you''ll see that the > confirm option needs to be passed in the second options hash, ie > link_to ''blah'', {options for url}, {other stuff here} >> Any idea why? >> >> Also when I set the :id attribute, either @pirate or @pirate.id >> work... why is that, and what''s the preferred form? >> > Because if you pass an activerecord object as the :id for a url rails > calls to_param on it, which by default returns id. The preferred form > these days would be to have the appropriate routes and do link_to > ''edit'', edit_pirate_path(@pirate) > > Fred >> Thanks! > > >-- Fernandez, Pablo. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---