README.rdoc in cereal_box-0.0.1 vs README.rdoc in cereal_box-0.0.2
- old
+ new
@@ -8,15 +8,15 @@
class ThingController < ActionController::Base
respond_to :json
def show
- @thing = Thing.find(1)
- @thing = @thing.as_json
- @thing[:other_things][:name] = thing.other_thing.name
- @thing[:other_related_thing][:name] = thing.other_related_thing.name
+ @thing = Thing.find(params[:id])
+ @thing_json = @thing.as_json
+ @thing_json[:other_things][:name] = @thing.other_thing.name
+ @thing_json[:other_related_thing][:name] = @thing.other_related_thing.name
- respond_with(@thing)
+ respond_with(@thing_json)
end
end
Specifically adding additional related information from other models
into the serialized hash of an object? Well, no more!