Friday, November 29, 2013

Rails: redirect_to with flash

Hi,

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: