If your request does not have the HTTP_REFERER defined,
redirect_to :back does not know where to redirect.
Ususally in this case root_url is used.
I hope, it will not be too difficult for you to combine
On Jun 5, 1:28 pm, Yiannis
<istoseli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hello
>
> I have a rails 3 app and I am trying to implement the redirect back
> action at access denied for cancan.
>
> If I try this in my application_controller:
> rescue_from CanCan::AccessDenied do |exception|
> redirect_to :back
> end
>
> It gives the following error:
> No HTTP_REFERER was set in the request to this action, so
> redirect_to :back could not be called successfully. If this is a test,
> make sure to specify request.env["HTTP_REFERER"].
>
> I can''t really understand why there is no http_referer, how is
back
> button working on views? Is it possible to implement a general back
> action for the cancan access denied exception?
>
> I like the devise approach of "back" method after sign in:
> def after_sign_in_path_for(resource)
> stored_location_for(resource)
> end
>
> It would be perfect if I could combine them.
>
> Thank you!
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.