Hi I recently migrated a Rails 2 app to Rails 3 and switched to Devise in the process. It is working well apart from one strange phenomenon. When I do redirects using javascript the user is logged out. Has anyone experienced something similar? Kindest regards Erik Lindblad -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yes, the problem is the authenticity token needs to be passed along with your data. There are various ways of doing this depending on your js library. Here''s how to access the data you need using prototype: var csrf_param = $$(''meta[name=csrf-param]'')[0].content; var csrf_token = $$(''meta[name=csrf-token]'')[0].content; On Thu, Apr 7, 2011 at 3:11 PM, Erik Lindblad <erik.l2c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi > > I recently migrated a Rails 2 app to Rails 3 and switched to Devise in > the process. It is working well apart from one strange phenomenon. > When I do redirects using javascript the user is logged out. Has > anyone experienced something similar? > > Kindest regards > > Erik Lindblad > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thx, this really made my day, having somewhere to start. Do you know how to do it from jquery? Regards Erik On 7 Apr, 22:59, Paul <p...-mzPrHiy5csbYtjvyW6yDsg@public.gmane.org> wrote:> Yes, the problem is the authenticity token needs to be passed along > with your data. There are various ways of doing this depending on your > js library. Here''s how to access the data you need using prototype: > > var csrf_param = $$(''meta[name=csrf-param]'')[0].content; > var csrf_token = $$(''meta[name=csrf-token]'')[0].content; > > > > > > > > On Thu, Apr 7, 2011 at 3:11 PM, Erik Lindblad <erik....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi > > > I recently migrated a Rails 2 app to Rails 3 and switched to Devise in > > the process. It is working well apart from one strange phenomenon. > > When I do redirects using javascript the user is logged out. Has > > anyone experienced something similar? > > > Kindest regards > > > Erik Lindblad > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hmm, I found out how to do it in jQuery (just use one $ instead of two) but I cannot get it to work. How should I include that in the js call to make it not log out? I have this in my controller: render :text => "window.location ''#{admin_start_list_path(@competition_class.id)}'';" All help appreciated. /Erik On 7 Apr, 23:31, Erik Lindblad <erik....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thx, this really made my day, having somewhere to start. Do you know > how to do it from jquery? > > Regards > > Erik > > On 7 Apr, 22:59, Paul <p...-mzPrHiy5csbYtjvyW6yDsg@public.gmane.org> wrote: > > > > > > > > > Yes, the problem is the authenticity token needs to be passed along > > with your data. There are various ways of doing this depending on your > > js library. Here''s how to access the data you need using prototype: > > > var csrf_param = $$(''meta[name=csrf-param]'')[0].content; > > var csrf_token = $$(''meta[name=csrf-token]'')[0].content; > > > On Thu, Apr 7, 2011 at 3:11 PM, Erik Lindblad <erik....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi > > > > I recently migrated a Rails 2 app to Rails 3 and switched to Devise in > > > the process. It is working well apart from one strange phenomenon. > > > When I do redirects using javascript the user is logged out. Has > > > anyone experienced something similar? > > > > Kindest regards > > > > Erik Lindblad > > > > -- > > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I found out how to do it. Add this to the URL: ?authenticity_token='' + encodeURIComponent(''<%form_authenticity_token %>) Entering here if someone else needs it. Thanks for the help, Rails community rocks as usual. /Erik On 7 Apr, 23:31, Erik Lindblad <erik....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thx, this really made my day, having somewhere to start. Do you know > how to do it from jquery? > > Regards > > Erik > > On 7 Apr, 22:59, Paul <p...-mzPrHiy5csbYtjvyW6yDsg@public.gmane.org> wrote: > > > > > > > > > Yes, the problem is the authenticity token needs to be passed along > > with your data. There are various ways of doing this depending on your > > js library. Here''s how to access the data you need using prototype: > > > var csrf_param = $$(''meta[name=csrf-param]'')[0].content; > > var csrf_token = $$(''meta[name=csrf-token]'')[0].content; > > > On Thu, Apr 7, 2011 at 3:11 PM, Erik Lindblad <erik....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi > > > > I recently migrated a Rails 2 app to Rails 3 and switched to Devise in > > > the process. It is working well apart from one strange phenomenon. > > > When I do redirects using javascript the user is logged out. Has > > > anyone experienced something similar? > > > > Kindest regards > > > > Erik Lindblad > > > > -- > > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.