Hi,
I am trying to get the response in xml format.
For that I have written following code
def user_details
@user=User.find(params[:id])
@company=@user.company
respond_to do |format|
format.xml {render :xml=> @user.to_xml(:include => @company)}
end
end
I am getting following error:-
"undefined method `macro' for nil:NilClass"
If the default to_xml isn't giving you want you want you can override
it yourself (to_xml does take quite a few options though - have a play
with them)
render :xml=> @user will only include the user attributes.
Is the assocation user has_one company ? If so (ie user has no
company_id attribute) then the easiest thing is probably to write a
method on user that returns the appropriate id and then use
the :methods option to to_xml to include that in the output