I would like to render a default 404 page on a certain condition in my Rails 5.1 app. I have this in my controller
def index
...
if worker
...
else
puts "page not found"
render :status => 404
end
end
However, even if the condition if met (my 404 branch is called), Rails is still trying to render my index.htrml.erb page, which is resulting in other errors because the expected model attributes are not there. Is there a way I can have a 404 status code returned without a page being rendered?