Class: BaseApiController
- Inherits:
-
InheritedResources::Base
- Object
- InheritedResources::Base
- BaseApiController
- Defined in:
- lib/generators/harbourmaster/install/templates/base_api_controller.rb
Instance Method Summary collapse
Instance Method Details
#collection ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/generators/harbourmaster/install/templates/base_api_controller.rb', line 7 def collection limit_per_page = params[:per_page] || nil @q = end_of_association_chain @q = @q.search(params[:q]) @q = @q.result @total_count = @q.length limit_per_page ||= @total_count # Pagination if params[:from] @q = @q.with_name_from(params[:from][:name], limit_per_page) if params[:from][:name] @q = @q.with_field_from(params[:from][:field], params[:from][:value]) if params[:from][:field] end @q.limit(limit_per_page) end |
#default_serializer_options ⇒ Object
25 26 27 |
# File 'lib/generators/harbourmaster/install/templates/base_api_controller.rb', line 25 def { meta: { deleted_ids: end_of_association_chain.show_deleted_ids(params[:visible_ids]), pagination: { total_objects: @total_count } } } end |