My Ruby on Rails web application has standard authentication. As the user logs in from the index page, I decided to model the index page as the “new” action of the “user_sessions” resource.
I decided to make the login form hidden using css, so that it could be made visible in a javascript launched modal dialog box.
The problem is now what do I do when the user has javascript turned off? Where do I send them to login?
I considered hiding the login form from javascript instead, so if javascript was turned off, the form would remain visible. Problem with this is that when the page is loading, the form will briefly appear before vanishing.
I wouldn’t go that way. Build a normal index page, and link to the login form. Then with
ujs, set the link asremote(so it’s managed asynchronously) and register its handler to show the resulting form in a popup.This way, a user without javascript will see the normal link, and a user with javascript will just trigger the modal dialog.