Pass resource to all requests (not only POST) to use it instead of ivar in RABL views with respond_to

This commit is contained in:
ccocchi 2012-09-19 18:03:40 +02:00
parent a97a8cd24f
commit 85eb4ebbf7

View File

@ -13,12 +13,12 @@ module RablRails
protected
def api_behavior(error)
rabl_options = options.merge(template: @api_template || RablRails.responder_default_template)
rabl_options = options.merge(template: @api_template || RablRails.responder_default_template, locals: { resource: resource })
if get?
controller.default_render rabl_options
elsif post?
controller.default_render rabl_options.merge!(status: :created, location: api_location, locals: { resource: resource })
controller.default_render rabl_options.merge!(status: :created, location: api_location)
else
head :no_content
end