5

I have some method in before_filter and I try to render status: 403. then I get:

Missing template v1/examples/index, v1/base/index, application/index with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :vcf, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}.

I can however render nothing: true or text: 'some text' without this error. What am I doing wrong?

ciembor
  • 7,189
  • 13
  • 59
  • 100

1 Answers1

16

Without your code it is hard to tell, but it sounds like you want to do the following:

render json: {}, status: :forbidden
Dave Powers
  • 2,051
  • 2
  • 30
  • 34
Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
  • such a frequent mistake. if the request format is not recognized as json it will search for a template - you solution fixes it. It should be approved – Matthieu Jun 02 '17 at 12:44