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:
parent
a97a8cd24f
commit
85eb4ebbf7
@ -13,12 +13,12 @@ module RablRails
|
|||||||
protected
|
protected
|
||||||
|
|
||||||
def api_behavior(error)
|
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?
|
if get?
|
||||||
controller.default_render rabl_options
|
controller.default_render rabl_options
|
||||||
elsif post?
|
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
|
else
|
||||||
head :no_content
|
head :no_content
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user