Forum: Ruby on Rails is it possible to render a modal dialog box from the server?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9d12e24c0a3aebe28b58682d517acdfb?d=identicon&s=25 ybernet@msn.com (Guest)
on 2009-04-14 15:35
(Received via mailing list)
I have a before filter that authorizes a user's credentials before
giving them access to any protected methods (pretty standard
practice). If they fail authorization, I want to direct them to a
chance to login or to create an account (also pretty standard
practice).

Here's the rub:
I want to offer them a login form in a small modal box overlayed on
their current screen. I know how to do this from the client side,
using javascript, but in this case, I want the server to render that
modal box (since it's the server that determines that the user's
credentials are missing).

Any ideas how to do this?

Thanks,
Yoram
054ea2f04b5592b91f8223796cc53979?d=identicon&s=25 Brendon Whateley (brendon)
on 2009-04-14 16:47
(Received via mailing list)
The server can only respond to client (browser) requests, so you have
to either render a login page and then redirect to the original
destination or you need to have some javascript to help with what you
want.  In short, the server can't MAKE the browser do anything...
9d12e24c0a3aebe28b58682d517acdfb?d=identicon&s=25 yoram (Guest)
on 2009-04-14 17:44
(Received via mailing list)
so you have
> to either render a login page

yes but - can i render that login page as an overlay modal box instead
of  a full page? i suspect
that the answer is not...

thanks for your reply
Dd2d775dea75b381edb1bbf0600a0907?d=identicon&s=25 Marnen Laibow-Koser (marnen)
on 2009-04-14 18:28
yoram wrote:
[...]
> yes but - can i render that login page as an overlay modal box instead
> of  a full page?
[...]

Sure, with appropriate JavaScript and a suitably constructed partial or
other HTML file.  (But remember to make it accessible also to users who
don't have JavaScript turned on.)

Also see if HTTP-Basic authentication is suitable for your needs.  With
this model, the server tells the browser that it wants login
credentials, and the browser presents a login dialog of some sort, so
that the server doesn't have to provide an HTML login form.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
91a72b0ad3e43e3ef3a31816667ec694?d=identicon&s=25 bill walton (Guest)
on 2009-04-16 15:49
(Received via mailing list)
On Tue, 2009-04-14 at 08:42 -0700, yoram wrote:

> yes but - can i render that login page as an overlay modal box instead
> of  a full page? i suspect
> that the answer is not...

Check out Craig Ambrose's Redbox plugin.

HTH,
Bill
This topic is locked and can not be replied to.