Voglio rilevare l'errore di azione sconosciuto in Rails 3, che mostra l'errore "Sconosciuto" sullo sviluppo e il 404.html sulla produzione. Ho provato a mettere questo gestore rescue_from
sul mio ApplicationController (e anche su un controller vero e proprio, nel caso) ma continuo a vedere il brutto errore.Catch Azione sconosciuta in Rails 3 per custom 404
Ho roba personalizzata sul 404 e non può essere un semplice file .html.
il mio percorso:
match '/user/:id/:action', controller: 'users'
L'URL che sto accedendo: /user/elado/xxx
Il codice rescue_from
:
rescue_from AbstractController::ActionNotFound, :with => :action_not_found
def action_not_found
render text: "action_not_found"
end
L'errore nel browser:
Unknown action
The action 'xxx' could not be found for UsersController
E nella console:
Started GET "/user/elado/xxx" for 127.0.0.1 at 2011-09-07 19:16:27 -0700
AbstractController::ActionNotFound (The action 'xxx' could not be found for UsersController):
Provato anche rescue_from ActionController::UnknownAction
.
Qualche suggerimento? Grazie!
Il seguente collegamento fornisce alcune informazioni utili, inoltre fornisce un esempio di come gestire meglio l'eccezione (3.2 o successiva). http://geekmonkey.org/articles/29-exception-applications-in-rails-3-2 – Agustin