Method: ActiveRecord::AttributeMethods#method_missing

Defined in:
lib/active_record/attribute_methods.rb

#method_missing(method, *args, &block) ⇒ Object

If we haven’t generated any methods yet, generate them, then see if we’ve created the method we’re looking for.



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/active_record/attribute_methods.rb', line 195

def method_missing(method, *args, &block) # :nodoc:
  self.class.define_attribute_methods
  if respond_to_without_attributes?(method)
    # make sure to invoke the correct attribute method, as we might have gotten here via a `super`
    # call in a overwritten attribute method
    if attribute_method = self.class.find_generated_attribute_method(method)
      # this is probably horribly slow, but should only happen at most once for a given AR class
      attribute_method.bind(self).call(*args, &block)
    else
      return super unless respond_to_missing?(method, true)
      send(method, *args, &block)
    end
  else
    super
  end
end