Search code examples
ruby-on-railsajaxauthenticationrjs

To implement Reddit's login feature in Rails, would I need to use RJS and remote_form_for?


A feature in Reddit that I like is the ajax login - you enter your username and password on the front page and you never leave the front page even if there is a login error. If your login succeeds, I think it simply does something like a flash[:message] onto the front page to say "login successful". If I wanted to do this in Rails, would that be a case of needing to use RJS + remote_form_for? Are there any other techniques in Rails that would allow me to do this?


Solution

  • RJS and remote_form_for are the Rails Way to do Ajax, but you certainly don't have to use them. Railscasts has a screencast on using RJS and Ajax to submit a form.

    If you prefer a different javascript library (such as jQuery), you can use its Ajax libraries to perform the correct actions.