Dave Rapin
2008-Feb-27 17:35 UTC
Rails 2.02 collection_select problem passing option and html_option hashes
Running into a strange issue and was wondering if others are experiencing it with the latest rails release. When using the collection_select helper and passing in a hash for the options or html_options params I consistently get the following error: syntax error, unexpected ''}'', expecting '')'' Not using a hash to pass the params works fine (for options at least, html_options doesn''t seem to). Let''s assume the following: Object to update: @product Methods to update: category_id Collection to pick from: @categories Category value field: id Category text field: name So this works and will give us the first option "Please select" in the drop down (due to prompt): collection_select( :product, :category_id, @categories, :id, :name, :prompt => true ) However, changing the options param to a hash like this: collection_select( :product, :category_id, @categories, :id, :name, {:prompt => true} ) Breaks the form producing this error. syntax error, unexpected ''}'', expecting '')'' The following attempts break it too: collection_select( :product, :category_id, @categories, :id, :name, {} ) collection_select( :product, :category_id, @categories, :id, :name, {}, {} ) collection_select( :product, :category_id, @categories, :id, :name, {}, {:onchange => "alert(''hi'')"} ) Out of ideas. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mark Bush
2008-Feb-27 19:34 UTC
Re: Rails 2.02 collection_select problem passing option and
Dave Rapin wrote:> When using the collection_select helper and passing in a hash for the > options or html_options params I consistently get the following error: > syntax error, unexpected ''}'', expecting '')''I''m sure this will be of no use to you, but I just stuck: <%= collection_select :user, :articles, @articles, :id, :title, {:prompt => true}, {:onchange => "alert(''hi'')"} %> into one of my views and it worked just fine, popup alert and all. Rails 2.0.2 on MacOS 10.5.1, ruby 1.8.6 -- 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 -~----------~----~----~----~------~----~------~--~---
Dave Rapin
2008-Feb-27 20:12 UTC
Re: Rails 2.02 collection_select problem passing option and
Very strange. Ok thanks. You''re on the latest rails release or on edge? Maybe it''s a haml problem for me then. On Feb 27, 2:34 pm, Mark Bush <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Dave Rapin wrote: > > When using the collection_select helper and passing in a hash for the > > options or html_options params I consistently get the following error: > > syntax error, unexpected ''}'', expecting '')'' > > I''m sure this will be of no use to you, but I just stuck: > > <%= collection_select :user, :articles, @articles, :id, > :title, {:prompt => true}, > {:onchange => "alert(''hi'')"} %> > > into one of my views and it worked just fine, popup alert and all. > > Rails 2.0.2 on MacOS 10.5.1, ruby 1.8.6 > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dave Rapin
2008-Feb-27 20:13 UTC
Re: Rails 2.02 collection_select problem passing option and
Nevermind. I see you''re on 2.02 same as me. Ok thanks for the update. Gotta be something else. On Feb 27, 3:12 pm, Dave Rapin <rap...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Very strange. Ok thanks. You''re on the latest rails release or on > edge? Maybe it''s a haml problem for me then. > > On Feb 27, 2:34 pm, Mark Bush <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > Dave Rapin wrote: > > > When using the collection_select helper and passing in a hash for the > > > options or html_options params I consistently get the following error: > > > syntax error, unexpected ''}'', expecting '')'' > > > I''m sure this will be of no use to you, but I just stuck: > > > <%= collection_select :user, :articles, @articles, :id, > > :title, {:prompt => true}, > > {:onchange => "alert(''hi'')"} %> > > > into one of my views and it worked just fine, popup alert and all. > > > Rails 2.0.2 on MacOS 10.5.1, ruby 1.8.6 > > > -- > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---