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:
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 !
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
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.
It dawned on me that instead of just having the window.location code in
the
template, to surround it with the appropriate
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
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 S. 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
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