Alexandr Kurilin
Alexandr Kurilin

Reputation: 7855

RESTful vs custom page flow, what's the right approach?

Newbie question, go easy on me :)

I've been struggling with reconciling the concept of designing entities of my system according to the RESTful model and with actually organizing the flow of my site in such a way that it's logic and makes sense to both me and the customer. Let me give you an example:

Let's hypothetically say I'm implementing a site for sharing movies in real life. You got a model for movies, and you got a model for users (with some auth / authz thrown in). I imagine it would be pretty straightforward to treat the movies as a REST resource and let users browse through them, and then you could have a series of relationships (joint table(s)) that would represent ownership, borrowing, and lending. So far so good.

Now, any site out there will have a concept of a user dashboard where you can see the current full state of the user and information related to him. Is the dashboard somehow a REST resource as well? I'd imagine it can't be because it really is very specific to each individual user. Where do I place it then? Do I just create a controller called UserDashboard and perhaps route the root (mysite.com/userdashboard) to a default action from the UserDashboard controller which can, for example, given the user id, display all of that user's relationships in the system?

Is that Rails way? Am I somehow breaking the RESTful paradigm that way?

Thank you!

Upvotes: 1

Views: 209

Answers (1)

Noel Frostpaw
Noel Frostpaw

Reputation: 4009

You can go two ways with this:

You can create an entity that represents the dashboard of your user and store seperate data in that entity, or you can create an action on the controller that represents the dashboard. Both would meet the REST standard as you'd uniquely identify a Dashboard by going to either /Dashboards(db_id) or by going to /users/4/Dashboard, either URI identifying a unique entity.

Upvotes: 1

Related Questions