Sha256: 0afc54d079ef4b5877d97f51d3773de772804e3efd4d17d18d8b8109c805febf

Contents?: true

Size: 840 Bytes

Versions: 6

Compression:

Stored size: 840 Bytes

Contents

class Manage::<%= controller_class_name %>Controller < Manage::BaseController
  inherit_resources
  defaults :route_prefix => 'manage'
  
  before_filter :make_filter, :only=>[:index]

  load_and_authorize_resource :class => <%= class_name %>
  
  def create
    create!{ manage_<%= plural_name %>_path }
  end
  
  def update
    update!{ manage_<%= plural_name %>_path }
  end
  
  def destroy
    destroy!{ manage_<%= plural_name %>_path }
  end
  
  protected
    
    def collection
      @<%= plural_name %> = (@<%= plural_name %> || end_of_association_chain).merge(@search.scoped).page(params[:page])
    end
    
    def make_filter
      @search = Sunrise::ModelFilter.new(<%= class_name %>, :attributes=>[ <%= model.attributes.keys.map{ |a| ":#{a}" }.join(', ') %> ] )
      @search.update_attributes(params[:search])
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sunrise-scaffold-0.1.5 lib/generators/sunrise/scaffold/templates/single/controller.rb
sunrise-scaffold-0.1.4 lib/generators/sunrise/scaffold/templates/single/controller.rb
sunrise-scaffold-0.1.3 lib/generators/sunrise_scaffold/templates/single/controller.rb
sunrise-scaffold-0.1.2 lib/generators/sunrise_scaffold/templates/single/controller.rb
sunrise-scaffold-0.1.1 lib/generators/sunrise_scaffold/templates/single/controller.rb
sunrise-scaffold-0.1.0 lib/generators/sunrise_scaffold/templates/single/controller.rb