Apr 11
From here comes a nice way of raising 404 errors in rails.
Inside application_controller.rb:
class Error404 < StandardError end class ApplicationController < ActionController::Base rescue_from Error404, with: :render_404 def render_404 respond_to do |format| format.html{render file: "#{RAILS_ROOT}/public/404.html", status: 404} format.all{render nothing: true, status: 404} end true end # etc. end
Then, inside the relevant controller:
raise Error404
Also, as explained on the above website, the last line true in render_404 means you can
render_404 and return