I have a model, say User
. I want to call /users
(users_controller#index
) and pass it basically a scope so it returns data based on:
- The format (js, json, html)
- The chart/grid/layout it will be rendered in (highcharts, basic html table, jquery flexigrid, etc.)
With inherited_resources
and has_scope
, you can do something like that but it's not quite it.
I want to return [{:page => 10, :cells => [{:name => "User A"}...]}]
if params are something like {:action => "index", :format => "js", :grid => "flexigrid"}
, and return [#<User name='User A'>...]
rendered in a haml template if it's just html.
How do I do that RESTfully in Rails with inherited resources?
Something like this:
class UsersController < InheritedResources::Base
respond_with :js, :method => :find_and_return_for_grid
end
Does this require me creating my own Responder?