I have a select box like: <%= select(''tournament'', ''name'', Tournament.find_all.collect {|tournament| tournament.name}) %> and I want to place a link_to near it to Edit, like <%= link_to ''Edit, :action => ''edit'' %> to edit just one of the options at a time. Any idea? Thanks, ro --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
rosoft2001 wrote:> I have a select box like: > > <%= select(''tournament'', ''name'', Tournament.find_all.collect > {|tournament| tournament.name}) %> > > and I want to place a link_to near it to Edit, like > > <%= link_to ''Edit, :action => ''edit'' %> > > to edit just one of the options at a time. > > Any idea? > > Thanks, > > roHi, you just grab the selected value in Edit method by using params[:tournament][''name''] in the edit method. from that method you can do whatever you want. I hope you understand for more Rails related Links Visitthe following links http://chennairails.blogspot.com ok bye -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 29 November 2006 07:34, rosoft2001 wrote:> I have a select box like: > > <%= select(''tournament'', ''name'', Tournament.find_all.collect > {|tournament| tournament.name}) %> > > and I want to place a link_to near it to Edit, like > > <%= link_to ''Edit, :action => ''edit'' %> > > to edit just one of the options at a time. > > Any idea?You can either use javascript magick to redirect to currently selected item edit page or instead of ''edit'' link put ''edit'' submit button and submit to action that will e.g. do redirect to item''s edit page. --~--~---------~--~----~------------~-------~--~----~ 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 still want to be a link, so I had the javascript idea too. I know how to do it in pure js, but here it''s another controller involved and I don''t know how to build the link for that redirect, not how to get the selected value. Any idea? Thanks, ro Maxim Kulkin wrote:> On 29 November 2006 07:34, rosoft2001 wrote: > > I have a select box like: > > > > <%= select(''tournament'', ''name'', Tournament.find_all.collect > > {|tournament| tournament.name}) %> > > > > and I want to place a link_to near it to Edit, like > > > > <%= link_to ''Edit, :action => ''edit'' %> > > > > to edit just one of the options at a time. > > > > Any idea? > You can either use javascript magick to redirect to currently selected item > edit page or instead of ''edit'' link put ''edit'' submit button and submit to > action that will e.g. do redirect to item''s edit page.--~--~---------~--~----~------------~-------~--~----~ 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 29 November 2006 17:32, rosoft2001 wrote:> I still want to be a link, so I had the javascript idea too. I know how > to do it in pure js, but here it''s another controller involved and I > don''t know how to build the link for that redirect, not how to get the > selected value. > > Any idea?Well, I guess, there is no support for such things in Rails yet. Here is my hack for it: def dynamic_link_to(title, url_options, html_options = {}) with_option = html_options[:with] || {} html_options.delete :with with_options.each { |param, element_id| url_options[param] = "dynamic_#{param}" } url = url_for(url_options) with_options.each { |param, element_id| url.gsub! ("dynamic_#{param}", "''+$F(''#{element_id}'')+''") } link_to title, ''#'', html_options.merge({ :onclick => "window.location = ''#{url}'';"}) end To use it you should do <select name="my_value"> ... </select> <%= dynamic_link_to ''Edit'', {:controller => ''foo'', :action => ''edit''}, :with => { :id => ''my_value'' } %> The link should look something like this: <a href=''#'' onclick="window.location = ''/foo/''+$F(''my_value'')+''/edit'';">Edit</a> PS check the code, I wrote it by memory.. haven''t got sources at hand.. But I guess, I''ll get the idea --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---