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! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Pickle < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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! > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Pickle <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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! > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---