我有一個模型,說User
。我想打電話/users
(users_controller#index
)和基本上傳遞一個範圍,以便它返回一個基於數據:Rails InheritedResources - 使用`find_and_return_for_some_grid`而不是`find(:all)`來響應JSON,?
- 格式(JS,JSON,HTML)
- 圖表/網格/佈局將在呈現(highcharts,基本的HTML表,jQuery的flexigrid等)
隨着inherited_resources
和has_scope
,你可以做這樣的事情,但它不是這麼回事。
我想回到[{:page => 10, :cells => [{:name => "User A"}...]}]
如果PARAMS是像{:action => "index", :format => "js", :grid => "flexigrid"}
,並返回一個HAML模板呈現[#<User name='User A'>...]
如果它只是HTML。
如何在帶有繼承資源的Rails中進行REST風格的操作?
事情是這樣的:
class UsersController < InheritedResources::Base
respond_with :js, :method => :find_and_return_for_grid
end
這是否需要我creating my own Responder?