I have this in routes.rb:
resources :emergencies, except: [:new, :edit, :destroy], defaults: { format: :json }
match '*path', to: 'application#page_not_found', via: :all
I also have this in application.rb:
config.exceptions_app = self.routes
And my application_controller.rb looks like this:
class ApplicationController < ActionController::Base
def page_not_found
render json: { message: 'page not found' }, status: :not_found
end
end
I have a set of test suites that tests the :new, :edit, and :destroy route. The routes for :edit and :destroy pass, returning the message page not found as expected, but the :new route returns null. Infact, anything like /emergencies/anything would render null, but something like /emergences/new/new would work correctly. Any idea on why this is happening and how I can fix it so that the route /emergencies/new is hitting the page_not_found action?
Aucun commentaire:
Enregistrer un commentaire