Sha256: 3f0795fbf223b8807887cd1b06b97665281d19d139f409ca78cbec0b0352385b

Contents?: true

Size: 1001 Bytes

Versions: 2

Compression:

Stored size: 1001 Bytes

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 -%>
<% (actions - DryScaffoldGenerator::DEFAULT_CONTROLLER_ACTIONS).each do |action| -%>
  # GET /<%= plural_name %>/<%= action.to_s %>
  def <%= action.to_s %>
  end
  
<% end -%>
<% if options[:pagination] && !options[:search] -%>
  protected
    
    def collection
      paginate_options ||= {}
      paginate_options[:page] ||= (params[:page] || 1)
      paginate_options[:per_page] ||= (params[:per_page] || 20)
      @<%= model_plural_name %> ||= end_of_association_chain.paginate(paginate_options)
    end
<% end %>

<% if options[:search]  -%>
  protected
    
    def collection
      @search = end_of_association_chain.search(params[:search])
      @<%= model_plural_name %>  = @search.paginate(:page => params[:page])
    end
<% end %>
        
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
blakechambers-dry_scaffold-0.3.6 generators/dry_scaffold/templates/controllers/inherited_resources_controller.rb
michel-dry_scaffold-0.3.5 generators/dry_scaffold/templates/controllers/inherited_resources_controller.rb