From: Michael Fellinger Date: 2009-03-03T01:28:39+09:00 Subject: Re: passing a method as a paramter On Tue, Mar 3, 2009 at 12:16 AM, Sarah Allen wrote: > Michael Fellinger wrote: >> On Mon, Mar 2, 2009 at 7:44 PM, Sarah Allen >> wrote: >>>>>      assert_not_nil record.errors.on(field) >>>>>    end >>>>>  end >>> >>> Any thoughts on how that could be called? >> >> It's the second example, you cannot obtain an instance of Method like >> you would do in Python or JavaScript by simply omitting the >> parenthesis, you have to use the Object#method method. >> >> All of these are equivalent: >> >> User.create >> User.create() >> User.method(:create).call >> User.send(:create) >> >> ^ manveru > > I get the error: (ActiveRecord::Base).create> is not a symbol > calling: >  assert_required_fields User.method(:create), :create, :email, > :lastname, :password Sorry, with rails all bets on normally behaving ruby code are off. ^ manveru > the code in my library uses send, not call > > Of course, I could just change the definition of assert_required_fields, > but since it is part of a plugin > (http://topfunky.net/svn/plugins/topfunky_power_tools/lib/topfunky/test_helper.rb > ), I figure there must be some standard way to call it > > Thanks for your help, > Sarah