Sha256: 51b913f0b5275badb20dfb3420ef40700543aa36ea2b6acfa5b3f5c6dbcc2956

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

module Admin

  class <%= name.pluralize %>Controller < BaseController

    handle_return_path

    PER_PAGE = 20

    def index
      @<%= @collection_name %> = <%= @class_name %>.ordered.paginate(page: params[:page], per_page: PER_PAGE)
    end

    def new
      @<%= @instance_name %> = <%= @class_name %>.new
    end

    def create
      @<%= @instance_name %> = <%= @class_name %>.new(params[:<%= @instance_name %>].permit!)
      if @<%= @instance_name %>.save
      redirect_or_render :edit
      else
        render :new
      end
    end

    def edit
      @<%= @instance_name %> = <%= @class_name %>.find(params[:id])
    end

    def update
      @<%= @instance_name %> = <%= @class_name %>.find(params[:id])
      if @<%= @instance_name %>.update_attributes(params[:<%= @instance_name %>].permit!)
      redirect_or_render :edit
      else
        render :edit
      end
    end

    def destroy
      @<%= @instance_name %> = <%= @class_name %>.find(params[:id])
      @<%= @instance_name %>.destroy
      redirect_to_last
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
coalla-cms-0.4.2.0 lib/generators/coalla/cms/news/templates/entity_controller_template.rb.erb
coalla-cms-0.5.2.4 lib/generators/coalla/cms/news/templates/entity_controller_template.rb.erb
coalla-cms-0.4.4.3 lib/generators/coalla/cms/news/templates/entity_controller_template.rb.erb
coalla-cms-0.5.1.9 lib/generators/coalla/cms/news/templates/entity_controller_template.rb.erb
coalla-cms-0.5.1.8 lib/generators/coalla/cms/news/templates/entity_controller_template.rb.erb