Module: Spree::Api::Responders::RablTemplate

Included in:
AppResponder
Defined in:
lib/spree/api/responders/rabl_template.rb

Instance Method Summary collapse

Instance Method Details

#api_behavior(error) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/spree/api/responders/rabl_template.rb', line 20

def api_behavior(error)
  if controller.params[:action] == "destroy"
    # Render a blank template
    super
  else
    # Do nothing and fallback to the default template
  end
end

#templateObject



16
17
18
# File 'lib/spree/api/responders/rabl_template.rb', line 16

def template
  request.headers['X-Spree-Template'] || controller.params[:template] || options[:default_template]
end

#to_formatObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/spree/api/responders/rabl_template.rb', line 5

def to_format
  if template
    render template, :status => options[:status] || 200
  else
    super
  end

rescue ActionView::MissingTemplate => e
  api_behavior(e)
end