ArgumentError: wrong number of arguments (0 for 1)
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/serialization.rb:75:in y' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/serialization.rb:75:in send’
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/serialization.rb:75:in `serializable_record’
…
@Julian: Actually there is an :include option in both the find and #to_json methods. With find it instructs ARec to construct a join and
bring back the associated model(s) in one db cycle. Similarly, in
to_json it instructs ARec to include the associations in the rendered
json. You might want to fact-check your ActiveRecord free-for-a-
limited-time video…
@Roel: I just tried the code below in my domain without problems.
Could the difference be that :include must name an association? In my
domain, User has_many :courts, :through=>:court_users
Here are my associations:
Foo has_one Bar
Bar belongs_to Foo
I am able to use to_json method if I only specify to include column x
from the bar object. If i include column y, that is when I get error.
Is there an issue using column named “y”?
From the link I provided above, it states this “Add
“Model.define_attribute_methods” to your rails after_initialize
callback so the “y” accessor is automatically generated.”
Where would I add that? To my model?
Any help is much appreciated.
Roel
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.