Question

How can I solve this? how can I find which open-uri module is clashing with my model.

Here is some output to make the question clearer:

m=MyModel.new
m.open
NoMethodError: private method `open' called for #<MyModel:0xcd889b4>
from /var/lib/gems/2.0.0/gems/activemodel-3.2.14/lib/active_model/attribute_methods.rb:404:in `method_missing'

Here is what that file contains near line 404:

def method_missing(method, *args, &block)
  if respond_to_without_attributes?(method, true)
    super # line 404
  else
    match = match_attribute_method?(method.to_s)
    match ? attribute_missing(match, *args, &block) : super
  end
end

I forgot to write the open-uri part, see:

m.open=Time.now
=> 2014-03-04 17:00:04 +0000
m.save
ArgumentError: wrong number of arguments (0 for 1+)
from /usr/lib/ruby/2.0.0/open-uri.rb:28:in `open'

Update

I just found that open is an invalid column name.

How to handle this? other than change column name, since it is used in a large codebase.

Était-ce utile?

La solution

Changing the column name now will mean less pain in future. Trying to work around the problem leaves you open for bigger issues down the line.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top