Concerns about starting a new "RESTfull compliant" site

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

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

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

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 2/21/07, diegal [email protected] wrote:

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

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

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! :wink:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs