For example, i’ve this model:
class User < ActiveRecord::Base
def foo
bar
end
end
When i do this:
<%= User.all.to_json %>
I get this:
[{“user”:{“created_at”:”2011-06-07T17:40:21-03:00″,”login”:”abcd”, “password”:”1234″,”updated_at”:”2011-06-07T18:10:04-03:00″}}]
How can i get foo on this json too? Also, foo is an activerecord too..
Thanks
It may also be useful to limit the attributes that are sent, you can do this with either the
:onlyand:exceptoptions. e.g. It is unlikely you will want the password in this data.