Hi All I''m trying to combine the from_for and select helpers Right now I have form_for :service, :url => ...... do |f| select("abc", "xyz_id", @my_arr.collect {|item| [ item, "bla" ] }, {:prompt => "opt1"} ) .... end What I want to do is something like .... f.select("abc", "xyz_id", @my_arr.collect {|item| [ item, "bla" ] }, {:prompt => "opt1"} ) .... (this doesn''t work) I''ve tried many things but I cannot get this to work, any suggestions ? thnx a lot LuCa -- 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 Jul 21, 4:20 pm, Luca Scaljery <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> select("abc", "xyz_id", @my_arr.collect {|item| [ item, "bla" ] }, > {:prompt => "opt1"} ) > > .... > end > > What I want to do is something like > > .... > f.select("abc", "xyz_id", @my_arr.collect {|item| [ item, "bla" ] },You shouldn''t need that first parameter (which effectively provided by the form_for) Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On Jul 21, 4:20�pm, Luca Scaljery <rails-mailing-l...@andreas-s.net> > wrote: >> � select("abc", "xyz_id", @my_arr.collect {|item| [ item, "bla" ] }, >> {:prompt => "opt1"} ) >> >> � .... >> � end >> >> What I want to do is something like >> >> � .... >> � f.select("abc", "xyz_id", @my_arr.collect {|item| [ item, "bla" ] }, > > You shouldn''t need that first parameter (which effectively provided by > the form_for) > > FredI tried f.select("xyz_id", @my_arr.collect {|item| [ item, "bla" ] }, {:prompt => "opt1"} ) but doesn''t work (error) -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
What do you want the user to see in the drop-down? What do you want stored in the xyz_id field of your @xyz object? I''m having a hard time understanding the .collect call in there. Does this run without error? f.select("xyz_id", @my_arr, {:prompt => "opt1"}) Cheers, -Roy -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Luca Scaljery Sent: Monday, July 21, 2008 1:41 PM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: form_for and select ( => f.select) Roy Pardee wrote:> What version of rails? > > Show us the whole form_for call please. > > Tell us about the error--what''s the message, and which line causes it?I''m using rails 2.0.2 In the view(haml): - form_for :xyz, :url => my_url(params[:my_id],@vals), :html => {:method => ''put'', :multipart => true} do |f| f.select("xyz_id", @my_arr.collect {|item| [ item, "bla" ] }, end The ERROR: undefined method `merge'' for [["A", "bla"], ["B", "bla"], ["C", "bla"]]:Array Trace: vendor/rails/actionpack/lib/action_view/helpers/form_options_helper.rb:4 20:in `select'' app/views/services/_abc.haml:34:in `_run_template_47app47views47xyz47_abc46haml'' /Library/Ruby/Gems/1.8/gems/haml-1.8.2/lib/haml/helpers/action_view_mods .rb:72:in `call'' /Library/Ruby/Gems/1.8/gems/haml-1.8.2/lib/haml/helpers/action_view_mods .rb:72:in `form_for'' /Library/Ruby/Gems/1.8/gems/haml-1.8.2/lib/haml/helpers.rb:336:in `call'' /Library/Ruby/Gems/1.8/gems/haml-1.8.2/lib/haml/helpers.rb:336:in `haml_bind_proc'' /Library/Ruby/Gems/1.8/gems/haml-1.8.2/lib/haml/helpers/action_view_mods .rb:76:in `form_for'' app/views/xyz/_abc.haml:1:in `_run_template_47app47views47xyz47_abc46haml'' /Library/Ruby/Gems/1.8/gems/haml-1.8.2/lib/haml/helpers/action_view_mods .rb:7:in `render'' /Library/Ruby/Gems/1.8/gems/haml-1.8.2/lib/haml/helpers/action_view_mods .rb:7:in `render'' /Library/Ruby/Gems/1.8/gems/haml-1.8.2/lib/haml/helpers/action_view_mods .rb:7:in `render'' app/views/xyz/abc.haml:1:in `_run_template_47app47views47xyz47abc46haml'' /Library/Ruby/Gems/1.8/gems/haml-1.8.2/lib/sass/plugin/rails.rb:19:in `process'' And in the controller/action I have @my_arr = %w(A B C) Hopefully it makes it makes sense -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Luca Scaljery wrote:> Roy Pardee wrote: >> What do you want the user to see in the drop-down? What do you want >> stored in the xyz_id field of your @xyz object? I''m having a hard time >> understanding the .collect call in there. >> >> Does this run without error? >> >> f.select("xyz_id", @my_arr, {:prompt => "opt1"}) >> >> Cheers, >> >> -Roy > > if I do that I get the following error > > undefined method `xyz_id'' for #<Xyz:0x4304cfcThe problem is solved. The problem occured due to the first 2 parameters. For example, this doesn''t work select("abc", "abc_id" .....) but this does select("abc", "def_id" .... ) so now it works for f.select too! thnx a lot for the help!! -- 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 Jul 22, 10:55 am, Luca Scaljery <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Roy Pardee wrote: > > What do you want the user to see in the drop-down? What do you want > > stored in the xyz_id field of your @xyz object? I''m having a hard time > > understanding the .collect call in there. > > > Does this run without error? > > > f.select("xyz_id", @my_arr, {:prompt => "opt1"}) > > > Cheers, > > > -Roy > > if I do that I get the following error > > undefined method `xyz_id'' for #<Xyz:0x4304cfcThen something is fundamentally scewed: why are you trying to edit xyz_id if Xyz doesn''t have xyz_id column? (also this would probably be a lot easier to follow with ''real'' class/column names) Fred> -- > 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On Jul 22, 10:55�am, Luca Scaljery <rails-mailing-l...@andreas-s.net> > wrote: >> >> > -Roy >> >> if I do that I get the following error >> >> undefined method `xyz_id'' for #<Xyz:0x4304cfc > > Then something is fundamentally scewed: why are you trying to edit > xyz_id if Xyz doesn''t have xyz_id column? (also this would probably be > a lot easier to follow with ''real'' class/column names) > > Fredyou''re right, next time I''ll do that, I thought things would be easier with xyz and abc :) -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---