Felix
Felix

Reputation: 5619

Rails Controller action render last page?

I want to redirect to page from where I come is that possible?

What I do:

Calling a controller function from an view, and when action is finished I want to render the same page like a back function?

Thanks

Upvotes: 2

Views: 4729

Answers (2)

Pere Joan Martorell
Pere Joan Martorell

Reputation: 3103

If what you want is actually render (not redirect) to the last rendered view you can do it in the following way:

render request.referer.split('/').last

It guesses the last rendered view from the request HTTP referer (the URL from which the controller action has been called). Note this approach it's quite fragile, but can be handy in most cases.

Upvotes: 1

Jimmy Baker
Jimmy Baker

Reputation: 3255

Use

redirect_to :back

You can also pass more params to it. Read more here: http://api.rubyonrails.org/classes/ActionController/Redirecting.html

Upvotes: 3

Related Questions