Anyone mind helping with he following, whatever I do I can''t get it to work quite right, I want the selection dropdown to show a list of enquiries maybe by Enquiry.firstname and when selected the show action to display the enquiry, I know this should be mega easy but I can''t get it to work with colleciton select. controller index action ------------------ def index @enquiries = Enquiry.find(:all, :order => ''created_at ASC'') end view --- <% form_tag :controller => ''enquiries'', :action => ''show'', :id => @enquiry do %> SELECT HELPER ? COLLECTION SELECT? <%= submit_tag "Show" %> controller view action ---------------- def show @enquiry = Enquiry.find(params[:id]) end -- 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 -~----------~----~----~----~------~----~------~--~---
anyone? I just need a basic dropdown which passes the id of the selected enquiry. -- 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 -~----------~----~----~----~------~----~------~--~---
bingo bob wrote:> > Anyone mind helping with he following, whatever I do I can''t get it to > work quite right, I want the selection dropdown to show a list of > enquiries maybe by Enquiry.firstname and when selected the show action > to display the enquiry, I know this should be mega easy but I can''t get > it to work with colleciton select. > > > controller index action > ------------------ > > def index > @enquiries = Enquiry.find(:all, :order => ''created_at ASC'') > end > > > view > --- > > <% form_tag :controller => ''enquiries'', :action => ''show'', :id => > @enquiry do %> ><% form_tag { :controller => ''enquiries'', :action => ''show'' } %> <%= collection_select :enquiry, :id, @enquiries, :id, :firstname %>> > <%= submit_tag "Show" %> > > > controller view action > ---------------- > > > def show >@enquiry = Enquiry.find(params[:enquiry][:id]> > endTry that. Hope it helps. NOTE: I didn''t test it, but I''m pretty sure it''s right, which means you may have to tweak it. ;) Also of note, if you want something different to show up in the select, you can add a method to your model that returns the proper text and substitute that for :firstname in your collection select. i.e. class Enquiry def last_comma_first self.lastname.to_s + '', '' + self.firstname.to_s end end <%= collection_select :enquiry, :id, @enquiries, :id, :last_comma_first %> Cheers, Darrik -- Darrik Mazey DMT Programming, LLC. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Darrick, That''s great thanks, I tried this before (or something very similar and it worked)...Here''s the problem though... That show action works your way from the collection select drop down... However.... When I do it this it brakes something else (the show action after I''ve editted a form). e.g this URL. http://localhost:3000/enquiries/show/5 I see why it''s broken I just don''t know how to fix it...so it''s like I''ve got two situations, one from the dropdown and one from a regular form and I''d like the show action to deal with both? Hope that makes sense... BTW I love the enhancement in my model which I did giving first initial then lastname... Any ideas? -- 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 -~----------~----~----~----~------~----~------~--~---
any ideas, does my show action need to change, or the collection select, OR the params passed from when I move to the show action from the edit ? -- 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 -~----------~----~----~----~------~----~------~--~---
bump... -- 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 -~----------~----~----~----~------~----~------~--~---
bingo bob wrote:> > > Darrick, > > That''s great thanks, I tried this before (or something very similar and > it worked)...Here''s the problem though... > > That show action works your way from the collection select drop down... > > However.... > When I do it this it brakes something else (the show action after I''ve > editted a form). > > e.g this URL. > > http://localhost:3000/enquiries/show/5If you''re using RESTful routes, that url should be: http://localhost:3000/enquiries/5/show Not sure how you''re getting to the other. Are you using the url generator methods? e.g. enquiry_url(@enquiry) and friends? If you use the url generator methods for all of your links, you shouldn''t have any problems. Use these as parameters to redirect_to and link_to. <%= link_to ''list'', enquiries_path %> ... or ... redirect_to enquiry_url(@enquiry) How are you generating the url you listed above? Cheers, Darrik --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
What makes you think your question is more important than everyone else''s? On Sep 13, 11:32 pm, bingo bob <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> bump... > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---