Why doesn’t answer_responses with json in this case? I am invoking an action with explicit .json (/tasks/4e3c1163a19d461203000106/items/4e4c27dfa19d46e0e400000a.json)
In my controller
class Tasks::TasksController < Tasks::BaseController respond_to :html, :js, :json def update @task = @taskgroup.update_task(params[:id], params[:task]) @taskgroup.save respond_with @task end end
When I flipped to_json and added a breakpoint, it didn’t hit. Answer:
{}
If I replaced response_with with an explicit call to_json:
respond_with @task do |format| format.json { render json: @task.to_json } end
The answer is perfect:
{ "_id":"4e4c27dfa19d46e0e400000a", "assigned_to":null, "comments" [{"_id":"4e4c2fd7a19d46e127000014", [SNIP]
In the latter case, it works fine, but I would like to find out why the first does not work. This happens for other controllers and models in my application. Not sure if this is a mangooid thing? (rails 3.0.9 / mongoid 2.1.8)
ericvg
source share