Friday, November 29, 2013

Rails: redirect_to with flash


In rails one can provide(not in older versions) flash messages directly in redirect_to method while residing in controller's action to redirect to different path like
redirect_to login_path, :notice => 'Please login'

But one thing needs attention here is, it works only for named routes and not for routes without names like

redirect_to {controller: 'session', action: 'login'}, :notice => 'Please login'

Small but this point should be taken in consideration.

1 comment:

The baffling IQ test

Getting 100 per cent means you “have a passion for perfection and you like to challenge yourself. You excel in finding problems and solutio...