On Mon, Jan 21, 2013 at 8:48 PM, Thijs De vries <[email protected]> wrote: > Hey Guys, > I used to have the following code: > > <%= form_for @something do |f| %> > <%= f.send :select, :state, [['AL', 'Alabama'], ['AK', 'Alaska'] #etc %> > <% end %> > > When I run this I get an exception because the kernel module method > select gets called expecting an array for the first arg but gets the > symbol :state instead. This is strange because f (an instance of > ActionView::Helpers::FormBuilder) has this method defined publicly. > > Looking at the rails code, it does not seem that anything fancy is being > done metaprogramming wise except for re-opening the class to define the > select method on the ActionView:: Helpers::FormBuilder class. This is a > public method and even if it was private, you would think that ruby > would look from the closest class first (being the FormBuilder class) > before looking up to the kernel module. > > Does anyone have any good documentation on the rules for ruby send on > how it determines which method gets called? > > The above issue can be reproduced with rails 3.2.10 and ruby 1.9.3 patch > level 327.
Not a Rails expert but I think there is a bug in your code: you do not want the _first_ equals sign. <%= form_for @something do |f| %> -> <% form_for @something do |f| %> Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ -- [email protected] | https://groups.google.com/d/forum/ruby-talk-google?hl=en
