Sha256: 7bedbfe8c63b7538d927a1c9ffec5ef8d2c567c3951644709055e51001dbd86c

Contents?: true

Size: 980 Bytes

Versions: 3

Compression:

Stored size: 980 Bytes

Contents

class Manage::<%= controller_class_name %>Controller < Manage::BaseController
  inherit_resources
  belongs_to :<%= parent_singular_name %>
  
  load_and_authorize_resource :<%= singular_name %>, :through => :<%= parent_singular_name %>
  
  has_scope :with_title, :as => :title, :only => :index
  order_by :created_at, :updated_at
  
  def create
    create!{ manage_<%= parent_singular_name %>_<%= plural_name %>_path(@<%= parent_singular_name %>.id) }
  end
  
  def update
    update!{ manage_<%= parent_singular_name %>_<%= plural_name %>_path(@<%= parent_singular_name %>.id) }
  end
  
  def destroy
    destroy!{ manage_<%= parent_singular_name %>_<%= plural_name %>_path(@<%= parent_singular_name %>.id) }
  end
  
  protected
    
    def begin_of_association_chain
      @<%= parent_singular_name %>
    end
    
    def collection
      @<%= plural_name %> = (@<%= plural_name %> || end_of_association_chain).order(search_filter.order).page(params[:page])
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sunrise-scaffold-0.2.2 lib/generators/sunrise/scaffold/templates/multiplay/controller.rb
sunrise-scaffold-0.2.1 lib/generators/sunrise/scaffold/templates/multiplay/controller.rb
sunrise-scaffold-0.2.0 lib/generators/sunrise/scaffold/templates/multiplay/controller.rb