# Restful\_authentication vs "from scratch"

**URL:** <https://www.ruby-forum.com/t/restful-authentication-vs-from-scratch/142953>\
**Category:** Rails\
**Created:** [July 13, 2008, 10:20pm UTC](https://www.ruby-forum.com/t/restful-authentication-vs-from-scratch/142953 "2008-07-13T22:20:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snitko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c0e974/32.png) [@snitko](https://www.ruby-forum.com/u/snitko)\
**Post date:** [July 13, 2008, 10:20pm UTC](https://www.ruby-forum.com/t/restful-authentication-vs-from-scratch/142953/1 "2008-07-13T22:20:50Z")

</div>

I’ve never done authentication in rails, so please don’t be rigorous.

The first thought was to use restful\_authentication plugin. Since I  
found no api online, and all instructions said, I have to use  
generator (which is not what I wanted - I already had a model and I  
needed to integrate authentication in it), I decided to create an  
empty project and to check out what code the generator puts in the  
model and other files.

What I found, I didn’t like. User model contained a bunch of lines  
with validators and other stuff. What I was looking for is one line,  
something like:

acts\_as\_authenticated

And that’s it. Why mix plugin code with the model code? So, my  
questions are:

1. Is there any manual or readme on how to integrate this plugin,  
avoiding any generators, keeping as much code as possible out of /app  
dir?
2. If no, is it worth writing authentication thing from scratch?

Any useful suggestions are welcome.

---

<div class="post-metadata">

**Author:** ![snitko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c0e974/32.png) [@snitko](https://www.ruby-forum.com/u/snitko)\
**Post date:** [July 15, 2008, 7:46am UTC](https://www.ruby-forum.com/t/restful-authentication-vs-from-scratch/142953/2 "2008-07-15T07:46:25Z")

</div>

I use restful\_authentication in pretty much all my Rails projects.

These are my opinions, and they are only opinions:

> And that’s it. Why mix plugin code with the model code? So, my  
> questions are:  
> All the stuff that gets applied to the User model by  
> restful\_authentication are perfect legitimate as model logic so it  
> seems to be in the right place to me.

> 1. Is there any manual or readme on how to integrate this plugin,  
> avoiding any generators, keeping as much code as possible out of /app  
> dir?  
> No, why should there be? The author expects the user of the plugin to  
> run the generator at the beginning of the project. This is the first  
> thing I do in all my projects needing authentication. That’s not to  
> say it wouldn’t fairly trivial to move the code over from a blank  
> project. There shouldn’t be that much work involved. Plus the  
> generators allow a --skip-migration option, but you’ll still need a  
> reasonably compatible User model.

> 1. If no, is it worth writing authentication thing from scratch?  
> I would not write my own from scratch. I have better things to do with  
> my valuable time.
