Render status: 403 causes "Missing template" error
Asked Answered
H

1

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?

Havana answered 9/9, 2015 at 14:9 Comment(2)
Post the code. It looks like you are trying to render a 403 page that you don't have. Check your public folder.Automatize
Hell yeah, I should render empty json hash + status... thanks!Havana
C
16

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

render json: {}, status: :forbidden
Climactic answered 9/9, 2015 at 14:26 Comment(1)
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 approvedDzungaria

© 2022 - 2024 — McMap. All rights reserved.