Sha256: d43bd5e50a62a26d36099f3d34654af1cf1b492a0ca263ff19fdbb70be7ec67b
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
class <%= controller_class_name %>Controller < InheritedResources::Base <% if actions -%> actions <%= symbol_array_to_expression(actions) %> <% end -%> <% if formats -%> respond_to <%= symbol_array_to_expression(formats) %> <% end -%> <% if actions -%> before_filter :load_resource, :only => [<%= symbol_array_to_expression(actions & DryScaffoldGenerator::DEFAULT_MEMBER_AUTOLOAD_ACTIONS) %>] <% end -%> <% if actions -%> before_filter :load_and_paginate_resources, :only => [<%= symbol_array_to_expression(actions & DryScaffoldGenerator::DEFAULT_COLLECTION_AUTOLOAD_ACTIONS) %>] <% end -%> <% (actions - DryScaffoldGenerator::DEFAULT_CONTROLLER_ACTIONS).each do |action| -%> # GET /<%= plural_name %>/<%= action.to_s %> def <%= action.to_s %> # TODO: Implement action "<%= plural_name %>/<%= action.to_s %>" end <% end -%> protected def collection <% if options[:pagination] -%> paginate_options ||= {} paginate_options[:page] ||= (params[:page] || 1) paginate_options[:per_page] ||= (params[:per_page] || 20) @<%= plural_name %> = @<%= model_plural_name %> ||= end_of_association_chain.paginate(paginate_options) <% else -%> @collection = @<%= model_plural_name %> ||= end_of_association_chain.all <% end -%> end alias :load_and_paginate_resources :collection def resource @resource = @<%= model_singular_name %> ||= end_of_association_chain.find(params[:id]) end alias :load_resource :resource end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grimen-dry_scaffold-0.2.6 | generators/dry_scaffold/templates/controllers/inherited_resources_controller.rb |