I want to use a controller that has a different name to the model it uses. Can i do this in rails? Something like class FooController < ApplicationController model => "AModelWithALongClunkyName" ... ?? Ie, to override rails configuration in this instance? -- 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 -~----------~----~----~----~------~----~------~--~---
Max Williams wrote:> I want to use a controller that has a different name to the model it > uses. Can i do this in rails? Something like > > class FooController < ApplicationController > model => "AModelWithALongClunkyName" > > ... > > ?? Ie, to override rails configuration in this instance?Never mind, i managed to figure it out: my problem was actually with resource_this, which was generating my controller methods. I just needed to pass a :class_name option to resource_this. -- 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 -~----------~----~----~----~------~----~------~--~---
Hi -- On Thu, 13 Mar 2008, Max Williams wrote:> > Max Williams wrote: >> I want to use a controller that has a different name to the model it >> uses. Can i do this in rails? Something like >> >> class FooController < ApplicationController >> model => "AModelWithALongClunkyName" >> >> ... >> >> ?? Ie, to override rails configuration in this instance? > > Never mind, i managed to figure it out: my problem was actually with > resource_this, which was generating my controller methods. I just > needed to pass a :class_name option to resource_this.In general it''s worth knowing that the controller-model linkage is essentially arbitrary. Controllers are just objects, and models are classes. All model classes are visible to all controllers. You have to decide how you want your domain controlled -- that is, how the gears work between your controller layer and your model layer. There are some high-level conventions and bundled behaviors, like resource routing, that save you from having to think it through completely from scratch every time, but it''s still always under your control. David -- Upcoming Rails training from David A. Black and Ruby Power and Light: ADVANCING WITH RAILS, April 14-17 2008, New York City CORE RAILS, June 24-27 2008, London (Skills Matter) See http://www.rubypal.com for details. Berlin dates coming soon! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I think one of the weaknesses in the RoR community right now is that everyone has just assumed that the default scaffolding for RESTful resources is THE way that resources are supposed to be viewed. There has not been a very good explanation (at least not one that anyone has listened to) that resources are addressable objects of any type. As such they do not necessarily map 1-1 with domain models. As I have pointed out previously, the restful_authentication plugin makes the point by manipulating a ''session'' object that has no domain model -- it''s purely a notional resource that relates to the user logged into the site. The scaffolding is a simplifying step, but it''s not the only way. As David says, the choice is yours. On Mar 13, 9:53 am, "David A. Black" <dbl...-0o/XNnkTkwhBDgjK7y7TUQ@public.gmane.org> wrote:> Hi -- > > > > On Thu, 13 Mar 2008, Max Williams wrote: > > > Max Williams wrote: > >> I want to use a controller that has a different name to the model it > >> uses. Can i do this in rails? Something like > > >> class FooController < ApplicationController > >> model => "AModelWithALongClunkyName" > > >> ... > > >> ?? Ie, to override rails configuration in this instance? > > > Never mind, i managed to figure it out: my problem was actually with > > resource_this, which was generating my controller methods. I just > > needed to pass a :class_name option to resource_this. > > In general it''s worth knowing that the controller-model linkage is > essentially arbitrary. Controllers are just objects, and models are > classes. All model classes are visible to all controllers. You have to > decide how you want your domain controlled -- that is, how the gears > work between your controller layer and your model layer. There are > some high-level conventions and bundled behaviors, like resource > routing, that save you from having to think it through completely from > scratch every time, but it''s still always under your control. > > David > > -- > Upcoming Rails training from David A. Black and Ruby Power and Light: > ADVANCING WITH RAILS, April 14-17 2008, New York City > CORE RAILS, June 24-27 2008, London (Skills Matter) > Seehttp://www.rubypal.comfor details. Berlin dates coming soon!--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
AndyV wrote:> I think one of the weaknesses in the RoR community right now is that > everyone has just assumed that the default scaffolding for RESTful > resources is THE way that resources are supposed to be viewed. There > has not been a very good explanation (at least not one that anyone has > listened to) that resources are addressable objects of any type. As > such they do not necessarily map 1-1 with domain models. As I have > pointed out previously, the restful_authentication plugin makes the > point by manipulating a ''session'' object that has no domain model -- > it''s purely a notional resource that relates to the user logged into > the site. > > The scaffolding is a simplifying step, but it''s not the only way. As > David says, the choice is yours.That''s all too true. My problem (and maybe others) is that i dove into the REStful stuff without fully understanding it (like they did with Rails) and so tended to slavishly copy the examples in every situation, which of course isn''t advisable. Thanks a lot guys. -- 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 -~----------~----~----~----~------~----~------~--~---
On 3/13/08, AndyV <arv7-HmMyXyqgL2CVc3sceRu5cw@public.gmane.org> wrote:> > I think one of the weaknesses in the RoR community right now is that > everyone has just assumed that the default scaffolding for RESTful > resources is THE way that resources are supposed to be viewed. There > has not been a very good explanation (at least not one that anyone has > listened to) that resources are addressable objects of any type. As > such they do not necessarily map 1-1 with domain models. As I have > pointed out previously, the restful_authentication plugin makes the > point by manipulating a ''session'' object that has no domain model -- > it''s purely a notional resource that relates to the user logged into > the site.Yep. Many people seem to have a mindset that resources ARE models, but to my mind resources are really aspects of controllers. I''d say that resources are controllers, except that in general a controller (can) represent(s) both a collection of resources and the individual elements in that collection. While it''s natural to use a(n) (ActiveRecord) model to implement persistent resources, it''s by no means the sole implementation. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.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 -~----------~----~----~----~------~----~------~--~---
Maybe we should have pitched a "What the heck is a resource" talk for RC08! On Mar 16, 10:49 am, "Rick DeNatale" <rick.denat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 3/13/08, AndyV <a...-HmMyXyqgL2CVc3sceRu5cw@public.gmane.org> wrote: > > > > > I think one of the weaknesses in the RoR community right now is that > > everyone has just assumed that the default scaffolding for RESTful > > resources is THE way that resources are supposed to be viewed. There > > has not been a very good explanation (at least not one that anyone has > > listened to) that resources are addressable objects of any type. As > > such they do not necessarily map 1-1 with domain models. As I have > > pointed out previously, the restful_authentication plugin makes the > > point by manipulating a ''session'' object that has no domain model -- > > it''s purely a notional resource that relates to the user logged into > > the site. > > Yep. Many people seem to have a mindset that resources ARE models, > but to my mind resources are really aspects of controllers. > > I''d say that resources are controllers, except that in general a > controller (can) represent(s) both a collection of resources and the > individual elements in that collection. > > While it''s natural to use a(n) (ActiveRecord) model to implement > persistent resources, it''s by no means the sole implementation. > > -- > Rick DeNatale > > My blog on Rubyhttp://talklikeaduck.denhaven2.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 -~----------~----~----~----~------~----~------~--~---