Main Contents

Authentication on Rails

May 2, 2009

You may have heard me whine that rails isn’t going to replace Java anytime soon. You probably heard from me as well that it is a fad. Well, it’s been almost 6 years since its launch and it has already proven it’s here to stay. Like a lot of technologies, it has also made its way into my own likings as well. I just can’t say I like ruby yet, but rails is a nicely written framework.

I’ve been developing a rails app for a RPG community project, and one of the features I had to add in was authentication. Coming from the CakePHP camp, I was expecting to find something similar to Cake’s Auth component in the Rails core, but they did not have it. Instead the community has a wide variety of plugins, although the restful_authentication plugin is the most popular.

I tried using it and had a couple newbie issues going on. First off, when i ran script/plugin install using the git URL, it didn’t do anything, but also didn’t give me an error, so I thought it was install. So when i tried running script/generate authenticated … told me that the generator was not installed. Took me a while to figure out the plugins are installed under the vendor folder, and as I went there, the directory was blank. Also took me a while to figure out that it was due to not having git installed, so I went ahead and downloaded git. 

Plugin installation went fine, and the generator also ran fine after that, but when I tried the /signup url, it gave me:

NameError in AccountsController#new

uninitialized constant Account::Authentication

So after some googling, I found nothing. Looking at that error, i checked the model the generator created, and turns out that Account::Authentication was supposed to be populated by   include Authentication, but it wasn’t being found to include.

What I had to do in order to solve it was copying the contents of the lib folder in the vendor/restful-authentication/lib to the main application /lib folder.

Thought I’d share so one may find this post when having that error and hopefully not loose 3 hours over it like I did.

Filed under: software engineering | Comments (0)

Leave a comment