Hi all. I''m just starting a new app from scratch, and want to do it RESTfully... I''ve seen many blog posts, articles, and DHH''s RailsConf keynote about REST and resources and still have some questions about it. I''ve no problems mapping some concepts to resources like the classics article, post, person, event, etc... But some aspects of a WebApp I find no REST answer, like a "homepage" which shows a summary of the latests articles, posts and events in the site. It''s not about 1 resource or a collection of resources of the same kind, it''s about a bunch of different resources. Which would be the best RESTful approach to this kind of functionality? I obviously missed some point here or haven''t realized it yet. Other examples I can think of: a dashboard, "about this site" pages, etc... A related question is how to manage "layout" related data. I mean, if I have a sidebar in my layout which needs some data to be retrieved in every request, I''d usually use a before_filter at the ApplicationController level. Is that kind of controller activity (doing things beyond the scope of the specific managed resource) still considered "clean" thinking in pure RESTfullness compliance? Thank you, Diego --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ball, Donald A Jr \(Library\)
2007-Feb-21 17:10 UTC
Re: Concerns about starting a new "RESTfull compliant" site
> I''ve no problems mapping some concepts to resources like the > classics article, post, person, event, etc... But some > aspects of a WebApp I find no REST answer, like a "homepage" > which shows a summary of the latests articles, posts and > events in the site. It''s not about 1 resource or a collection > of resources of the same kind, it''s about a bunch of > different resources.In this case, your homepage is a resource which summarizes the latest changes to the articles, posts, and events resources. In this case, GET is a meaningful request, while POST, PUT, and DELETE are probably not. Your dashboard resource probably acts similarly, while your "about this site" resource probably behaves more like a traditional static file. - donald --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 21 feb, 15:10, "Ball, Donald A Jr \(Library\)" <donald.b...-GjtI+QwuxAR68HQyEA6aog@public.gmane.org> wrote:> > I''ve no problems mapping some concepts to resources like the > > classics article, post, person, event, etc... But some > > aspects of a WebApp I find no REST answer, like a "homepage" > > which shows a summary of the latests articles, posts and > > events in the site. It''s not about 1 resource or a collection > > of resources of the same kind, it''s about a bunch of > > different resources. > > In this case, your homepage is a resource which summarizes the latest > changes to the articles, posts, and events resources. In this case, GET > is a meaningful request, while POST, PUT, and DELETE are probably not. > Your dashboard resource probably acts similarly, while your "about this > site" resource probably behaves more like a traditional static file.Mmm... Ok. But I see no Homepage model (or dashboard, or about) in that. Would it be teorically ok (thinking of REST and resources) to have a HomepageController which manages no model? All examples I''ve seen have a 1 to 1 relation between a Controller and a Model. Diego --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Russell Norris
2007-Feb-21 18:48 UTC
Re: Concerns about starting a new "RESTfull compliant" site
For my app, I discovered that my dashboard seemed to fit nicely as the index method of my sessions controller. You log in [new/create] and out [delete], change options about what you want to view [edit/update] and read a summary of sorts about what''s going on this session [index]. This might not work in your case but hopefully it''s a good example of how to look at things from a different angle. RSL On 2/21/07, diegal <diego.algorta-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi all. > > I''m just starting a new app from scratch, and want to do it > RESTfully... > > I''ve seen many blog posts, articles, and DHH''s RailsConf keynote about > REST and resources and still have some questions about it. > > I''ve no problems mapping some concepts to resources like the classics > article, post, person, event, etc... But some aspects of a WebApp I > find no REST answer, like a "homepage" which shows a summary of the > latests articles, posts and events in the site. It''s not about 1 > resource or a collection of resources of the same kind, it''s about a > bunch of different resources. > > Which would be the best RESTful approach to this kind of > functionality? > > I obviously missed some point here or haven''t realized it yet. > > Other examples I can think of: a dashboard, "about this site" pages, > etc... > > A related question is how to manage "layout" related data. I mean, if > I have a sidebar in my layout which needs some data to be retrieved in > every request, I''d usually use a before_filter at the > ApplicationController level. Is that kind of controller activity > (doing things beyond the scope of the specific managed resource) still > considered "clean" thinking in pure RESTfullness compliance? > > Thank you, > Diego > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
That seems ok. But maybe it seems a bit special for that particular case. One more related concern is how to support different "views" of the same resource. I mean, how could I have an "administrative" interface where I can CRUD resources. For example, the path "/articles" would show the list of articles with it''s summaries so a site visitor can read them. But if I''m in the administrative interface "/articles" should render completely different showing just the titles and the classic edit & destroy links per article. Should I configure a new "aspect" route/action caled "admin" or something? map.resources :articles, :collection => {:admin => :get} # /articles;admin ArticlesController < ActiveController def admin @articles = ... end end It just doesn''t feel good... Thanks for the help. Diego On 21 feb, 16:48, "Russell Norris" <sco...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> For my app, I discovered that my dashboard seemed to fit nicely as the index > method of my sessions controller. You log in [new/create] and out [delete], > change options about what you want to view [edit/update] and read a summary > of sorts about what''s going on this session [index]. This might not work in > your case but hopefully it''s a good example of how to look at things from a > different angle. > > RSL > > On 2/21/07, diegal <diego.algo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi all. > > > I''m just starting a new app from scratch, and want to do it > > RESTfully... > > > I''ve seen many blog posts, articles, and DHH''s RailsConf keynote about > > REST and resources and still have some questions about it. > > > I''ve no problems mapping some concepts to resources like the classics > > article, post, person, event, etc... But some aspects of a WebApp I > > find no REST answer, like a "homepage" which shows a summary of the > > latests articles, posts and events in the site. It''s not about 1 > > resource or a collection of resources of the same kind, it''s about a > > bunch of different resources. > > > Which would be the best RESTful approach to this kind of > > functionality? > > > I obviously missed some point here or haven''t realized it yet. > > > Other examples I can think of: a dashboard, "about this site" pages, > > etc... > > > A related question is how to manage "layout" related data. I mean, if > > I have a sidebar in my layout which needs some data to be retrieved in > > every request, I''d usually use a before_filter at the > > ApplicationController level. Is that kind of controller activity > > (doing things beyond the scope of the specific managed resource) still > > considered "clean" thinking in pure RESTfullness compliance? > > > Thank you, > > Diego--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Paul Barry
2007-Feb-22 04:01 UTC
Re: Concerns about starting a new "RESTfull compliant" site
Good question, I''ve been wondering the same thing myself. My current solution is to have an ArticlesController and an Admin::ArticlesController, but that doesn''t feel right either. On Feb 21, 2:17 pm, "diegal" <diego.algo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> That seems ok. But maybe it seems a bit special for that particular > case. > > One more related concern is how to support different "views" of the > same resource. I mean, how could I have an "administrative" interface > where I can CRUD resources. For example, the path "/articles" would > show the list of articles with it''s summaries so a site visitor can > read them. But if I''m in the administrative interface "/articles" > should render completely different showing just the titles and the > classic edit & destroy links per article. > Should I configure a new "aspect" route/action caled "admin" or > something? > map.resources :articles, :collection => {:admin => :get} > # /articles;admin > > ArticlesController < ActiveController > def admin > @articles = ... > end > end > > It just doesn''t feel good... > > Thanks for the help. > Diego > > On 21 feb, 16:48, "Russell Norris" <sco...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > For my app, I discovered that my dashboard seemed to fit nicely as the index > > method of my sessions controller. You log in [new/create] and out [delete], > > change options about what you want to view [edit/update] and read a summary > > of sorts about what''s going on this session [index]. This might not work in > > your case but hopefully it''s a good example of how to look at things from a > > different angle. > > > RSL > > > On 2/21/07, diegal <diego.algo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi all. > > > > I''m just starting a new app from scratch, and want to do it > > > RESTfully... > > > > I''ve seen many blog posts, articles, and DHH''s RailsConf keynote about > > > REST and resources and still have some questions about it. > > > > I''ve no problems mapping some concepts to resources like the classics > > > article, post, person, event, etc... But some aspects of a WebApp I > > > find no REST answer, like a "homepage" which shows a summary of the > > > latests articles, posts and events in the site. It''s not about 1 > > > resource or a collection of resources of the same kind, it''s about a > > > bunch of different resources. > > > > Which would be the best RESTful approach to this kind of > > > functionality? > > > > I obviously missed some point here or haven''t realized it yet. > > > > Other examples I can think of: a dashboard, "about this site" pages, > > > etc... > > > > A related question is how to manage "layout" related data. I mean, if > > > I have a sidebar in my layout which needs some data to be retrieved in > > > every request, I''d usually use a before_filter at the > > > ApplicationController level. Is that kind of controller activity > > > (doing things beyond the scope of the specific managed resource) still > > > considered "clean" thinking in pure RESTfullness compliance? > > > > Thank you, > > > Diego--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Pat Maddox
2007-Feb-22 04:28 UTC
Re: Concerns about starting a new "RESTfull compliant" site
On 2/21/07, diegal <diego.algorta-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi all. > > I''m just starting a new app from scratch, and want to do it > RESTfully... > > I''ve seen many blog posts, articles, and DHH''s RailsConf keynote about > REST and resources and still have some questions about it. > > I''ve no problems mapping some concepts to resources like the classics > article, post, person, event, etc... But some aspects of a WebApp I > find no REST answer, like a "homepage" which shows a summary of the > latests articles, posts and events in the site. It''s not about 1 > resource or a collection of resources of the same kind, it''s about a > bunch of different resources.In your homepage example, what''s the resource that you''re exposing to people? ... I can''t think of one either. It''s really just a landing zone with links to interesting resources. I guess maybe you could use a map metaphor, in which case you''d have a MapsController. It''s overkill though. Bottom line is that this sort of thing doesn''t fit the resource paradigm. So don''t try to shoehorn it. For stuff like the homepage or an "about us" page, I just create a MainController. The default route ('':controller/:action/:id'') works fine. You end up with stuff like /main/about_us, /main/privacy, etc. REST is cool and all, but for some things it doesn''t provide any value to expose them as resources, and it can just be plain awkward.> A related question is how to manage "layout" related data. I mean, if > I have a sidebar in my layout which needs some data to be retrieved in > every request, I''d usually use a before_filter at the > ApplicationController level. Is that kind of controller activity > (doing things beyond the scope of the specific managed resource) still > considered "clean" thinking in pure RESTfullness compliance?Of course. The "meat" of your code is going to be finding/modifying the resource. I put that in quotes because for the most part it''s going to be very simple, basic code. But the idea is that you''re just giving the user a representation of some resource. If you want to make the surrounding layout pretty, or provide useful information or links, go for it. Pat --~--~---------~--~----~------------~-------~--~----~ 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''ve been researching about REST and all... and since I feel many people has the same questions, I decided to sum them up in another thread. I suggest we move this conversation to that thread instead: http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/7448542a9ea0a567 Diego On 22 feb, 02:28, "Pat Maddox" <perg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 2/21/07,diegal<diego.algo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi all. > > > I''m just starting a new app from scratch, and want to do it > > RESTfully... > > > I''ve seen many blog posts, articles, and DHH''s RailsConf keynote about > > REST and resources and still have some questions about it. > > > I''ve no problems mapping some concepts to resources like the classics > > article, post, person, event, etc... But some aspects of a WebApp I > > find no REST answer, like a "homepage" which shows a summary of the > > latests articles, posts and events in the site. It''s not about 1 > > resource or a collection of resources of the same kind, it''s about a > > bunch of different resources. > > In your homepage example, what''s the resource that you''re exposing to people? > > ... > > I can''t think of one either. It''s really just a landing zone with > links to interesting resources. I guess maybe you could use a map > metaphor, in which case you''d have a MapsController. > > It''s overkill though. Bottom line is that this sort of thing doesn''t > fit the resource paradigm. So don''t try to shoehorn it. > > For stuff like the homepage or an "about us" page, I just create a > MainController. The default route ('':controller/:action/:id'') works > fine. You end up with stuff like /main/about_us, /main/privacy, etc. > > REST is cool and all, but for some things it doesn''t provide any value > to expose them as resources, and it can just be plain awkward. > > > A related question is how to manage "layout" related data. I mean, if > > I have a sidebar in my layout which needs some data to be retrieved in > > every request, I''d usually use a before_filter at the > > ApplicationController level. Is that kind of controller activity > > (doing things beyond the scope of the specific managed resource) still > > considered "clean" thinking in pure RESTfullness compliance? > > Of course. > > The "meat" of your code is going to be finding/modifying the resource. > I put that in quotes because for the most part it''s going to be very > simple, basic code. But the idea is that you''re just giving the user > a representation of some resource. If you want to make the > surrounding layout pretty, or provide useful information or links, go > for it. > > Pat--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chris Grant
2007-Mar-06 07:24 UTC
Re: Concerns about starting a new "RESTfull compliant" site
I don''t know what I was looking at but, since checking the official Trac (thought I was there before), I''m finding myself wrong on this one. Thanks for keeping me honest! ;) On Feb 23, 1:52 am, "diegal" <diego.algo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve been researching aboutRESTand all... and since I feel many > people has the same questions, I decided to sum them up in another > thread. > > I suggest we move this conversation to that thread instead: > > http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/... > > Diego > > On 22 feb, 02:28, "Pat Maddox" <perg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On 2/21/07,diegal<diego.algo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi all. > > > > I''m just starting a new app from scratch, and want to do it > > > RESTfully... > > > > I''ve seen many blog posts, articles, and DHH''s RailsConf keynote about > > >RESTand resources and still have some questions about it. > > > > I''ve no problems mapping some concepts to resources like the classics > > > article, post, person, event, etc... But some aspects of a WebApp I > > > find noRESTanswer, like a "homepage" which shows a summary of the > > > latests articles, posts and events in the site. It''s not about 1 > > > resource or acollectionof resources of the same kind, it''s about a > > > bunch of different resources. > > > In your homepage example, what''s the resource that you''re exposing to people? > > > ... > > > I can''t think of one either. It''s really just a landing zone with > > links to interesting resources. I guess maybe you could use a map > > metaphor, in which case you''d have a MapsController. > > > It''s overkill though. Bottom line is that this sort of thing doesn''t > > fit the resource paradigm. So don''t try to shoehorn it. > > > For stuff like the homepage or an "about us" page, I just create a > > MainController. The default route ('':controller/:action/:id'') works > > fine. You end up with stuff like /main/about_us, /main/privacy, etc. > > >RESTis cool and all, but for some things it doesn''t provide any value > > to expose them as resources, and it can just be plain awkward. > > > > A related question is how to manage "layout" related data. I mean, if > > > I have a sidebar in my layout which needs some data to be retrieved in > > > every request, I''d usually use a before_filter at the > > > ApplicationController level. Is that kind of controller activity > > > (doing things beyond the scope of the specific managed resource) still > > > considered "clean" thinking in pure RESTfullness compliance? > > > Of course. > > > The "meat" of your code is going to be finding/modifying the resource. > > I put that in quotes because for the most part it''s going to be very > > simple, basic code. But the idea is that you''re just giving the user > > a representation of some resource. If you want to make the > > surrounding layout pretty, or provide useful information or links, go > > for it. > > > Pat--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---