# Resources

**URL:** <https://www.ruby-forum.com/t/resources/131546>\
**Category:** Rails\
**Created:** [March 11, 2008, 8:08am UTC](https://www.ruby-forum.com/t/resources/131546 "2008-03-11T08:08:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bepickle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e19b73/32.png) [@bepickle](https://www.ruby-forum.com/u/bepickle)\
**Post date:** [March 11, 2008, 8:08am UTC](https://www.ruby-forum.com/t/resources/131546/1 "2008-03-11T08:08:45Z")

</div>

Hi, I’m confused about resources. When should one choose to use the  
resource/REST approach to a model?

For example, for the user model, should I choose to make the user a  
resource or should I just use the controller only approach with no REST  
involved?

What I’m doing first is making a registration page for a user. Should I  
start off with

# ruby script/generate resource User

( If I use this approach how do I automatically generate the “7 golden  
actions?” )

or

# ruby script/generate model User

# ruby script/generate controller User

?

I’ve seen tutorials on how to create resources and use REST, but don’t  
understand when to use the approach.

Any advice or links to references would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![bepickle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e19b73/32.png) [@bepickle](https://www.ruby-forum.com/u/bepickle)\
**Post date:** [March 11, 2008, 1:14pm UTC](https://www.ruby-forum.com/t/resources/131546/2 "2008-03-11T13:14:03Z")

</div>

If you’re looking to build a simple authentication system, there’s  
already  
plenty out there.

I recommend using acts\_as\_authenticated, but if you’re looking for  
something  
restful, give restful\_authentication a shot.

On Tue, Mar 11, 2008 at 5:38 PM, Big P. \<  
removed\_email\_address@domain.invalid\> wrote:

> # ruby script/generate resource User
> 
> I’ve seen tutorials on how to create resources and use REST, but don’t  
> understand when to use the approach.
> 
> ## Any advice or links to references would be greatly appreciated!
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![bepickle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e19b73/32.png) [@bepickle](https://www.ruby-forum.com/u/bepickle)\
**Post date:** [March 11, 2008, 4:35pm UTC](https://www.ruby-forum.com/t/resources/131546/3 "2008-03-11T16:35:44Z")

</div>

You use a model any time you want to keep data around. In the example  
you provide, you presumably want to keep information about the user in  
your application so you would create a User model and fill it with all  
the business logic required to maintain it.

Resources and REST are about how you _access_ models. That’s the  
basic difference. What may be confusing is that generate/scaffold  
creates both a RESTful API and a model. It may lead you to believe  
that there is a ‘resource’ and a ‘model’ or that in some cases they  
are synonymous… but they’re not. Models~data, resources~data access  
via HTTP

The restful\_autentication plugin (one of those many authentication  
systems that Ryan refers to while missing the general question you’re  
asking) will demonstrate a good example of models and resources. With  
that plugin you create a single model (User) with a standard resource  
(via UsersController). You also create a SessionController that  
manages only the concept of a ‘user session’ but has no persistent  
data… and thus no model behind it.

HTH,  
AndyV

On Mar 11, 3:08 am, Big P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
