I would like to have a login box setup so that if incorrect info is submitted, the box "shakes" via Effect.Shake. If the correct information is submitted, I want to redirect to some other page. The only solution I''ve found is the following, which is pretty ugly, as it displays the javascript I''m invoking on the page prior to the redirect. Here is the code: The Form ===========<%= form_remote_tag(:update => ''message'', :complete => evaluate_remote_response, :url => {:controller => ''login'', :action => ''login''}) %> The Action ===========if logged_in render(:text => "window.location.href = ''http://0.0.0.0:3000/admin'';") else render(:layout => false, :action => ''bad_login'') <-- which is just a template with an Effect.Shake So, is there any other way to do a redirect from an action via a form_remote_tag than using the window.location hack ? Crossing my fingers there is a way :) TIA ! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060130/f39a3674/attachment-0001.html
redirect_to :controller => "admin" , :action => "index" adam On 1/30/06, Dylan Stamat <dylans@gmail.com> wrote:> I would like to have a login box setup so that if incorrect info is > submitted, the box "shakes" via Effect.Shake. > If the correct information is submitted, I want to redirect to some other > page. > > The only solution I''ve found is the following, which is pretty ugly, as it > displays the javascript I''m invoking on the page prior to the redirect. > Here is the code: > > > The Form > ===========> <%= form_remote_tag(:update => ''message'', > :complete => > evaluate_remote_response, > :url => > {:controller => ''login'', :action => ''login''}) %> > > The Action > ===========> if logged_in > render(:text => "window.location.href = ''http://0.0.0.0:3000/admin'';") > else > render(:layout => false, :action => ''bad_login'') <-- which is just a > template with an Effect.Shake > > > So, is there any other way to do a redirect from an action via a > form_remote_tag than using the window.location hack ? > Crossing my fingers there is a way :) > TIA ! > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Adam, I thought that would work too... but it doesn''t ! Setup a little test, and you''ll see what I mean. Doing this window.location thing is all I can get to work. Check this thread out: http://thread.gmane.org/gmane.comp.lang.ruby.rails/14202 On 1/30/06, Adam Denenberg <straightflush@gmail.com> wrote:> > redirect_to :controller => "admin" , :action => "index" > > adam > > On 1/30/06, Dylan Stamat <dylans@gmail.com> wrote: > > I would like to have a login box setup so that if incorrect info is > > submitted, the box "shakes" via Effect.Shake. > > If the correct information is submitted, I want to redirect to some > other > > page. > > > > The only solution I''ve found is the following, which is pretty ugly, as > it > > displays the javascript I''m invoking on the page prior to the redirect. > > Here is the code: > > > > > > The Form > > ===========> > <%= form_remote_tag(:update => ''message'', > > :complete => > > evaluate_remote_response, > > :url => > > {:controller => ''login'', :action => ''login''}) %> > > > > The Action > > ===========> > if logged_in > > render(:text => "window.location.href = ''http://0.0.0.0:3000/admin''; > ") > > else > > render(:layout => false, :action => ''bad_login'') <-- which is just > a > > template with an Effect.Shake > > > > > > So, is there any other way to do a redirect from an action via a > > form_remote_tag than using the window.location hack ? > > Crossing my fingers there is a way :) > > TIA ! > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060130/91894d7f/attachment.html
So, if anybody is interested... Since I''m using an ":update" within the form_remote_tag, the template being rendered from the "redirect_to" is simply being displayed on the same page as the login form. So, still not working :) On 1/30/06, Dylan Stamat <dylans@gmail.com> wrote:> > Adam, I thought that would work too... but it doesn''t ! Setup a little > test, and you''ll see what I mean. > Doing this window.location thing is all I can get to work. Check this > thread out: > http://thread.gmane.org/gmane.comp.lang.ruby.rails/14202 > > > > On 1/30/06, Adam Denenberg <straightflush@gmail.com > wrote: > > > > redirect_to :controller => "admin" , :action => "index" > > > > adam > > > > On 1/30/06, Dylan Stamat <dylans@gmail.com> wrote: > > > I would like to have a login box setup so that if incorrect info is > > > submitted, the box "shakes" via Effect.Shake. > > > If the correct information is submitted, I want to redirect to some > > other > > > page. > > > > > > The only solution I''ve found is the following, which is pretty ugly, > > as it > > > displays the javascript I''m invoking on the page prior to the > > redirect. > > > Here is the code: > > > > > > > > > The Form > > > ===========> > > <%= form_remote_tag(:update => ''message'', > > > :complete => > > > evaluate_remote_response, > > > :url => > > > {:controller => ''login'', :action => ''login''}) %> > > > > > > The Action > > > ===========> > > if logged_in > > > render(:text => " window.location.href = '' > > http://0.0.0.0:3000/admin''; <http://0.0.0.0:3000/admin%27;>") > > > else > > > render(:layout => false, :action => ''bad_login'') <-- which is > > just a > > > template with an Effect.Shake > > > > > > > > > So, is there any other way to do a redirect from an action via a > > > form_remote_tag than using the window.location hack ? > > > Crossing my fingers there is a way :) > > > TIA ! > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060201/92f21db3/attachment.html
Yah I never got that to work.. so I gave up and took out Ajax call and made it a simple call On 2/1/06, Dylan Stamat <dylans@gmail.com> wrote:> > So, if anybody is interested... > > Since I''m using an ":update" within the form_remote_tag, the template > being rendered from the "redirect_to" is simply being displayed on the same > page as the login form. > > So, still not working :) > > > > On 1/30/06, Dylan Stamat <dylans@gmail.com> wrote: > > > > Adam, I thought that would work too... but it doesn''t ! Setup a little > > test, and you''ll see what I mean. > > Doing this window.location thing is all I can get to work. Check this > > thread out: > > http://thread.gmane.org/gmane.comp.lang.ruby.rails/14202 > > > > > > > > On 1/30/06, Adam Denenberg < straightflush@gmail.com > wrote: > > > > > > redirect_to :controller => "admin" , :action => "index" > > > > > > adam > > > > > > On 1/30/06, Dylan Stamat <dylans@gmail.com> wrote: > > > > I would like to have a login box setup so that if incorrect info is > > > > submitted, the box "shakes" via Effect.Shake. > > > > If the correct information is submitted, I want to redirect to some > > > other > > > > page. > > > > > > > > The only solution I''ve found is the following, which is pretty ugly, > > > as it > > > > displays the javascript I''m invoking on the page prior to the > > > redirect. > > > > Here is the code: > > > > > > > > > > > > The Form > > > > ===========> > > > <%= form_remote_tag(:update => ''message'', > > > > :complete => > > > > evaluate_remote_response, > > > > :url => > > > > {:controller => ''login'', :action => ''login''}) %> > > > > > > > > The Action > > > > ===========> > > > if logged_in > > > > render(:text => " window.location.href = '' > > > http://0.0.0.0:3000/admin''; <http://0.0.0.0:3000/admin%27;>") > > > > else > > > > render(:layout => false, :action => ''bad_login'') <-- which is > > > just a > > > > template with an Effect.Shake > > > > > > > > > > > > So, is there any other way to do a redirect from an action via a > > > > form_remote_tag than using the window.location hack ? > > > > Crossing my fingers there is a way :) > > > > TIA ! > > > > > > > > _______________________________________________ > > > > Rails mailing list > > > > Rails@lists.rubyonrails.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Rgds, --Siva Jagadeesan http://www.varcasa.com/ My First Rails Project. Powered by Typo and soon by RForum too -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060201/dbbc2edd/attachment.html
Awesome... thanks Siva ! That gives me the motivation to just strip out the Ajax, as the window.location trick is uuuugly :) Thanks again ! On 2/1/06, Siva Jagadeesan <sivajagdev@gmail.com> wrote:> > Yah I never got that to work.. so I gave up and took out Ajax call and > made it a simple call > > On 2/1/06, Dylan Stamat <dylans@gmail.com> wrote: > > > > So, if anybody is interested... > > > > Since I''m using an ":update" within the form_remote_tag, the template > > being rendered from the "redirect_to" is simply being displayed on the same > > page as the login form. > > > > So, still not working :) > > > > > > > > On 1/30/06, Dylan Stamat <dylans@gmail.com> wrote: > > > > > > Adam, I thought that would work too... but it doesn''t ! Setup a > > > little test, and you''ll see what I mean. > > > Doing this window.location thing is all I can get to work. Check this > > > thread out: > > > http://thread.gmane.org/gmane.comp.lang.ruby.rails/14202 > > > > > > > > > > > > On 1/30/06, Adam Denenberg < straightflush@gmail.com > wrote: > > > > > > > > redirect_to :controller => "admin" , :action => "index" > > > > > > > > adam > > > > > > > > On 1/30/06, Dylan Stamat <dylans@gmail.com> wrote: > > > > > I would like to have a login box setup so that if incorrect info > > > > is > > > > > submitted, the box "shakes" via Effect.Shake. > > > > > If the correct information is submitted, I want to redirect to > > > > some other > > > > > page. > > > > > > > > > > The only solution I''ve found is the following, which is pretty > > > > ugly, as it > > > > > displays the javascript I''m invoking on the page prior to the > > > > redirect. > > > > > Here is the code: > > > > > > > > > > > > > > > The Form > > > > > ===========> > > > > <%= form_remote_tag(:update => ''message'', > > > > > :complete => > > > > > evaluate_remote_response, > > > > > :url => > > > > > {:controller => ''login'', :action => ''login''}) %> > > > > > > > > > > The Action > > > > > ===========> > > > > if logged_in > > > > > render(:text => " window.location.href = ''http://0.0.0.0:3000/admin'';<http://0.0.0.0:3000/admin%27;> > > > > ") > > > > > else > > > > > render(:layout => false, :action => ''bad_login'') <-- which is > > > > just a > > > > > template with an Effect.Shake > > > > > > > > > > > > > > > So, is there any other way to do a redirect from an action via a > > > > > form_remote_tag than using the window.location hack ? > > > > > Crossing my fingers there is a way :) > > > > > TIA ! > > > > > > > > > > _______________________________________________ > > > > > Rails mailing list > > > > > Rails@lists.rubyonrails.org > > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > Rails mailing list > > > > Rails@lists.rubyonrails.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > -- > > Rgds, > --Siva Jagadeesan > http://www.varcasa.com/ > My First Rails Project. Powered by Typo and soon by RForum too > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060201/ea119557/attachment.html
Hey Siva ! It dawned on me that instead of just having the window.location code in the template, to surround it with the appropriate <script>window.location...etc</script> tags. When the page renders, the script is run, and it redirects fine :) If you use a "url_for" to create the href, it makes it even cleaner. So, the box shakes on a invalid login, and redirects me to the correct page (all clean and pretty like) on a valid login. Just thought I''d pass that along :) =Dylan On 2/1/06, Dylan Stamat <dylans@gmail.com> wrote:> > Awesome... thanks Siva ! That gives me the motivation to just strip out > the Ajax, as the window.location trick is uuuugly :) > Thanks again ! > > > > On 2/1/06, Siva Jagadeesan <sivajagdev@gmail.com> wrote: > > > > Yah I never got that to work.. so I gave up and took out Ajax call and > > made it a simple call > > > > On 2/1/06, Dylan Stamat <dylans@gmail.com> wrote: > > > > > > So, if anybody is interested... > > > > > > Since I''m using an ":update" within the form_remote_tag, the template > > > being rendered from the "redirect_to" is simply being displayed on the same > > > page as the login form. > > > > > > So, still not working :) > > > > > > > > > > > > On 1/30/06, Dylan Stamat <dylans@gmail.com> wrote: > > > > > > > > Adam, I thought that would work too... but it doesn''t ! Setup a > > > > little test, and you''ll see what I mean. > > > > Doing this window.location thing is all I can get to work. Check > > > > this thread out: > > > > http://thread.gmane.org/gmane.comp.lang.ruby.rails/14202 > > > > > > > > > > > > > > > > On 1/30/06, Adam Denenberg < straightflush@gmail.com > wrote: > > > > > > > > > > redirect_to :controller => "admin" , :action => "index" > > > > > > > > > > adam > > > > > > > > > > On 1/30/06, Dylan Stamat <dylans@gmail.com> wrote: > > > > > > I would like to have a login box setup so that if incorrect info > > > > > is > > > > > > submitted, the box "shakes" via Effect.Shake. > > > > > > If the correct information is submitted, I want to redirect to > > > > > some other > > > > > > page. > > > > > > > > > > > > The only solution I''ve found is the following, which is pretty > > > > > ugly, as it > > > > > > displays the javascript I''m invoking on the page prior to the > > > > > redirect. > > > > > > Here is the code: > > > > > > > > > > > > > > > > > > The Form > > > > > > ===========> > > > > > <%= form_remote_tag(:update => ''message'', > > > > > > :complete => > > > > > > evaluate_remote_response, > > > > > > :url => > > > > > > {:controller => ''login'', :action => ''login''}) %> > > > > > > > > > > > > The Action > > > > > > ===========> > > > > > if logged_in > > > > > > render(:text => " window.location.href = ''http://0.0.0.0:3000/admin'';<http://0.0.0.0:3000/admin%27;> > > > > > ") > > > > > > else > > > > > > render(:layout => false, :action => ''bad_login'') <-- which > > > > > is just a > > > > > > template with an Effect.Shake > > > > > > > > > > > > > > > > > > So, is there any other way to do a redirect from an action via a > > > > > > > > > > > form_remote_tag than using the window.location hack ? > > > > > > Crossing my fingers there is a way :) > > > > > > TIA ! > > > > > > > > > > > > _______________________________________________ > > > > > > Rails mailing list > > > > > > Rails@lists.rubyonrails.org > > > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > Rails mailing list > > > > > Rails@lists.rubyonrails.org > > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > > > -- > > > > Rgds, > > --Siva Jagadeesan > > http://www.varcasa.com/ > > My First Rails Project. Powered by Typo and soon by RForum too > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060203/fc05f28d/attachment-0001.html
Hey Dylan That is great!!! Now u have motivated me to try it :) Rgds, --Siva Jagadeesan http://www.varcasa.com/ My First Rails Project. Education Through Collabration -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060204/4dc78a34/attachment-0001.html
How has this worked for you? Can someone post the exact code so that the redirect stuff doesnt display? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
could you be a bit more precise? no idea what you mean. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
wont it still replace the update DIV with a blank partial instead, it will still be a delay and you will see your screen with that DIV replaced for a split second before the redirect even though you wont see the javascript actually show up. No? Dylan Stamat wrote:> Hey Siva ! > > It dawned on me that instead of just having the window.location code in > the > template, to surround it with the appropriate > <script>window.location...etc</script> > tags. > > When the page renders, the script is run, and it redirects fine :) > If you use a "url_for" to create the href, it makes it even cleaner. > > So, the box shakes on a invalid login, and redirects me to the correct > page > (all clean and pretty like) on a valid login. > Just thought I''d pass that along :) > => Dylan-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---