lib/jtable-rails/action_controller.rb in jtable-rails-0.1.4 vs lib/jtable-rails/action_controller.rb in jtable-rails-0.2.0
- old
+ new
@@ -1,9 +1,9 @@
module JTable
module ActionController
- def jtable_for_json(rel, jtable_params)
+ def jtable_for_json(jtable_name, rel, jtable_params)
jtable_params = HashWithIndifferentAccess.new(jtable_params)
- items = rel.jtable_paginate(jtable_params[:limit], jtable_params[:offset])
- {:total_items => rel.count, :items => items.collect(&:jtable_item)}
+ items = rel.send("jtable_#{jtable_name}_paginate",jtable_params[:limit], jtable_params[:offset])
+ {:total_items => rel.count, :items => items.collect(&("jtable_#{jtable_name}_item").to_sym)}
end
end
end
\ No newline at end of file