Undefined method with alias_method_chain

825 Views Asked by At

My model has attribute html. When I try to use alias_method_chain with setter html=, I get the error undefined method `name=' for class `Banner' But I use alias_method_chain with another attribute.

class Banner < ActiveRecord::Base

  def file_with_metadata_handling=(uploaded_file)
    # ...
  end

  def html_with_format_checking=(banner_html)
    # ...
  end

  # works well
  alias_method_chain :file=, :metadata_handling

  # undefined method html=
  alias_method_chain :html=, :format_checking
end

Method is defined

Banner.new.respond_to? :html=
 => true 
1

There are 1 best solutions below

0
On BEST ANSWER

Model defines attribute's getters & setters dynamically. So alias_method_chain had't found setter for attribute.