# Concerns about starting a new "RESTfull compliant" site

**URL:** <https://www.ruby-forum.com/t/concerns-about-starting-a-new-restfull-compliant-site/86380>\
**Category:** Rails\
**Created:** [February 21, 2007, 9:49pm UTC](https://www.ruby-forum.com/t/concerns-about-starting-a-new-restfull-compliant-site/86380 "2007-02-21T21:49:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![diegal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7993a0/32.png) [@diegal](https://www.ruby-forum.com/u/diegal)\
**Post date:** [February 21, 2007, 9:49pm UTC](https://www.ruby-forum.com/t/concerns-about-starting-a-new-restfull-compliant-site/86380/1 "2007-02-21T21:49:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![diegal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7993a0/32.png) [@diegal](https://www.ruby-forum.com/u/diegal)\
**Post date:** [February 21, 2007, 11:14pm UTC](https://www.ruby-forum.com/t/concerns-about-starting-a-new-restfull-compliant-site/86380/2 "2007-02-21T23:14:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![diegal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7993a0/32.png) [@diegal](https://www.ruby-forum.com/u/diegal)\
**Post date:** [February 21, 2007, 11:28pm UTC](https://www.ruby-forum.com/t/concerns-about-starting-a-new-restfull-compliant-site/86380/3 "2007-02-21T23:28:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![diegal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7993a0/32.png) [@diegal](https://www.ruby-forum.com/u/diegal)\
**Post date:** [February 22, 2007, 5:02am UTC](https://www.ruby-forum.com/t/concerns-about-starting-a-new-restfull-compliant-site/86380/4 "2007-02-22T05:02:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![diegal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7993a0/32.png) [@diegal](https://www.ruby-forum.com/u/diegal)\
**Post date:** [February 22, 2007, 5:30am UTC](https://www.ruby-forum.com/t/concerns-about-starting-a-new-restfull-compliant-site/86380/5 "2007-02-22T05:30:31Z")

</div>

On 2/21/07, diegal [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![diegal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7993a0/32.png) [@diegal](https://www.ruby-forum.com/u/diegal)\
**Post date:** [February 23, 2007, 8:52am UTC](https://www.ruby-forum.com/t/concerns-about-starting-a-new-restfull-compliant-site/86380/6 "2007-02-23T08:52:46Z")

</div>

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](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/7448542a9ea0a567)

Diego

---

<div class="post-metadata">

**Author:** ![diegal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7993a0/32.png) [@diegal](https://www.ruby-forum.com/u/diegal)\
**Post date:** [March 6, 2007, 8:25am UTC](https://www.ruby-forum.com/t/concerns-about-starting-a-new-restfull-compliant-site/86380/7 "2007-03-06T08:25:55Z")

</div>

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! 😉
