end
def all @all ||= OtherModel.find_by_my_model_id(self.id)
end
…
View :
<% for myModel in @list_of_myModels %>
<%=debug(myModel.stats)%>
throws "can’t dup Fixnum " error
Nothing to do with that ticket you found.
You’ve overriden the instance method new, not the class method new, so
when you do MyStats.new, you’re calling the original
ActiveRecord::Base initialize, which expects a hash of options as its
argument. It dups that hash and so you get your error.
Either way, don’t override new. Either override initialize (and
remember to call super) or use the after_initialize callback.
Fred
Also you should be overriding initialize, not new (or possibly using
the after_initialize callback).
, and either way you’ve got to call the superclass constructor, or bad
stuff will happen
Fred
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.