Hello,
Having trouble with generating some json. I am trying to render an
single active record result to json like this:
@data = User.find(1)
respond_with(@data, :include => :status)
The json result is:
{
-user: {
address: null
email: “[email protected]”
first_name: “Test”
last_name: “Man”
status_id: 1
username: “testguy”
status: { }
}
}
So whats the problem? The problem is that the :include=>:status seems
to not bring over the relation. In my User model I have a
belongs_to :status. How do i get this to work on a single result set?
When I do this:
@data = User.where("id = 1")
respond_with(@data, :include => :status)
The relation shows in the json result set fine this way. But its
within an array of objects, which i do not want.
Any ideas?