Correctly pass resource for simple render. Only fetch template name
when needed
This commit is contained in:
parent
85eb4ebbf7
commit
137234e705
@ -7,13 +7,19 @@ module RablRails
|
||||
class Responder < ActionController::Responder
|
||||
def initialize(controller, resources, options = {})
|
||||
super
|
||||
@api_template = @controller.respond_to?(:responder_default_template, true) ? controller.send(:responder_default_template) : nil
|
||||
if options[:locals]
|
||||
options[:locals][:resource] = resource
|
||||
else
|
||||
options[:locals] = { resource: resource }
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def api_behavior(error)
|
||||
rabl_options = options.merge(template: @api_template || RablRails.responder_default_template, locals: { resource: resource })
|
||||
template = @controller.respond_to?(:responder_default_template, true) ? controller.send(:responder_default_template)
|
||||
: RablRails.responder_default_template
|
||||
rabl_options = options.merge(template: template)
|
||||
|
||||
if get?
|
||||
controller.default_render rabl_options
|
||||
|
Loading…
Reference in New Issue
Block a user