Sha256: ed6a60d0aecef2d5209535b27ab6631a3b9633dfb14c333702fe3ca8f1df3728

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

class Admin::<%= plural_class_name %>Controller < ApplicationController
  menu_item	:<%= plural_name %>	
  respond_to :html

  def index
    @<%= plural_name %> = <%= class_name %>.paginate :page => params[:page],
      :per_page => 15
    respond_with(:admin, @<%= plural_name %>)      
  end

  def show
    @<%= singular_name %> = <%= class_name %>.find(params[:id])
    respond_with(:admin, @<%= singular_name %>)
  end

  def new
    @<%= singular_name %> = <%= class_name %>.new
    respond_with(:admin, @<%= singular_name %>)
  end

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

  def create
    @<%= singular_name %> = <%= class_name %>.new(params[:<%= singular_name %>])
    flash[:notice] = '<%= class_name %> foi criado com sucesso.' if @<%= singular_name %>.save
    respond_with(:admin, @<%= singular_name %>)
  end

  def update
  	@<%= singular_name %> = <%= class_name %>.new(params[:id])
    flash[:notice] = '<%= class_name %> foi alterado com sucesso.' if @<%= singular_name  %>.update_attributes(params[:<%= singular_name %>])
    respond_with(:admin, @<%= singular_name %>)
  end

  def destroy
    @<%= singular_name %> = <%= class_name %>.find(params[:id])
    flash[:notice] = '<%= class_name %> foi excluĂ­do com sucesso.' if @<%= singular_name %>.destroy 
    respond_with(:admin, @<%= singular_name %>)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flexi_generators-0.2.1 lib/generators/flexi_scaffold/templates/controller.rb
flexi_generators-0.2.0 lib/generators/flexi_scaffold/templates/controller.rb