Hi there, I''d like to know if there is a solution to the scenario when using acts_as_authenticated and ajax: I have an action in my controller which is protected by login via acts_as_authenticated. Now, this action can be called both by human interaction, as well as ajax requests. (It is an add to cart link). It works great as long as I am in an authenticated session. Now, I want to display this add to cart link regardless if I am logged in or not (very important). When I switch off Javascript, I get redirected nicely to the login form when I click it. With Javascript on, and thus ajax working, the ajax requests gets redirected to the login form (which I can see in the server log), but obviously the human is never shown a login screen - for him, nothing at all happens. Is it possible to redirect the "page" if the ajax requests is redirected, so the login form is shown and the user is able to proceed? What would be a better solution, if that''s not possible...I am kinda out of ideas. Thanks for your help, Rene --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Oh, and I forgot to say...using a page.redirect in the RJS for the "add to cart" action does not work as this action is never hit because it is protected with the before_filter :login_required of acts_as_authenticated... --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rene
2007-Sep-11 10:29 UTC
Re: acts_as_authenticated redirect on ajax requests <- Solution
Google was good to me today, here is the solution for the acts_as_authenticated method: http://projects.wh.techno-weenie.net/changesets/2203 Now, it says I can overwrite the access_denied method in the controller, but that doesn''t seem to work. Anyway, I''ll edit the original. On 11 Sep., 12:05, Rene <benediktla...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Oh, and I forgot to say...using a page.redirect in the RJS for the > "add to cart" action does not work as this action is never hit because > it is protected with the before_filter :login_required of > acts_as_authenticated...--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---