Fearless Fool wrote:
> In my quest to practice good style, I'm a bit stumped on the following.
> 
> Assume an app that lets a user visualize recent web activity on various
> domains ("user has many domains").  In ordinary RESTful style, the path
> /user/:user_id/domain invokes 'index' and lists all the domains, the
> path /user/:user_id/domain/:domain_id shows particulars about one
> domain.
> 
> Our app needs a 'display graph' button on the 'show' page to plot
> historical activity for a particular domain.  The plot page has lots of
> options (set time scale, filter different kinds of packets, etc), and I
> can imagine these being tacked onto a path as query strings.
> 
> I'm a bit stumped as to how this really fits into RESTful style.  Would
> you create a Plot controller ("domain has one plot") and control it with
> a path like /user/:user_id/domain/:domain_id/plot?plotoptions...  ?

No.  The basic 7 REST actions are common, not gospel.  There's nothing 
wrong with making plot a custom REST action (route would be the same as 
above, but on the same footing with domain/:domain_id/edit ).

And please: use shallow routes.  There's probably no reason to have the 
user_id in the domain path.

> 
> Also, the app calls for radically different page layouts depending on
> selected display style (e.g. plot vs table view) -- can one controller
> invoke multiple views?  Or must you create one controller per view?

What do you mean here?

> 
> And finally, would you back the controller with a Plot model?  Except
> for caching complex plots, I don't see a real motivation for db
> persistence, unless, of course, the Rails framework really wants a Plot
> model to go with a Plot controller.

You don't have to have a model for each controller.  You don't have to 
have a controller for each model.  You don't have to have a database 
table for each model.

> 
> I welcome your insights...
> 
> - ff

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to