xjq233p_1
xjq233p_1

Reputation: 8060

Rails, getting flash to work on redirection?

my root_path is basically redirecting to the most popular story at this instant.

my root is handled by pages#home action, which just redirects the user away to story_path(id).

when a user access an unauthorized page, I redirect that user to the root_url with the message "access denied." However, this doesn't work because at root the user is again redirected.

Any way to fix this?

Upvotes: 0

Views: 231

Answers (2)

cogline
cogline

Reputation: 59

@Alok, Reading the doc from the link you post also provides:

redirect_to root_url, :notice => "You have successfully logged out"

Upvotes: 0

Alok Swain
Alok Swain

Reputation: 6519

If you are redirecting and want to persist the flash for an extra request, you could do that using

flash.keep

More info can be found from the Rails Guides.

Upvotes: 4

Related Questions