Topic: A RESTful Homepage

I'm in the process of wrapping my head around RESTful design, and so far am comfortable understanding how it applies to resources.

Where I'm struggling is thinking how you would apply this to a homepage, or 'portal' of information: a page that would display, say, the latest 5 news posts, 5 events, etc.  There'd also be a menu on this page allowing the user to navigate to the news index, or the events index page.  At the moment I'm approaching this by having the news and event resource.

Should I create a 'browse' resource or such for the homepage?

Your thoughts are greatly appreciated.


Re: A RESTful Homepage

REST should not be used for every situation, IMO.

It works best when dealing with CRUD models, to get instant output of various formats (and also instant docs) Something like a homepage works best as a custom controller which references your RESTful resources.

Re: A RESTful Homepage

Well said pimpmaster, I agree. The main exception to this is if your home page focuses on something that is already handled by a REST controller. For example, if you're building a forum engine and you want the home page to list all of the forums then you may want to turn the forum index action into the home page.

But in your case the home page takes on many responsibilities. I recommend creating a "home" controller to do this (non-RESTful).

If your home page was super simple and mostly static, then I would recommend creating an "info" controller or something similar to handle all of your mostly static pages.

Railscasts - Free Ruby on Rails Screencasts

Re: A RESTful Homepage

Cheers guys, this is exactly what I was thinking!  I'm glad to see I'm not missing a trick.