Sha256: c9385cd8afed030d54a5765bae39511bbe3e82a3c4d8bcf84bdfe76bbbb59ce3

Contents?: true

Size: 1.63 KB

Versions: 10

Compression:

Stored size: 1.63 KB

Contents

class Admin::<%= class_name.pluralize %>Controller < AdminController
  
  respond_to :html, :xml, :json
  
  def index
    respond_with(:admin, @<%= plural_table_name %> = <%= class_name %>.order("updated_at DESC").page(params[:page]))
  end

  # GET <%= route_url %>/1
  # GET <%= route_url %>/1.xml
  def show
    @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
    respond_with(:admin, @<%= singular_table_name %>)
  end

  # GET <%= route_url %>/new
  # GET <%= route_url %>/new.xml
  def new
    @<%= singular_table_name %> = <%= orm_class.build(class_name) %>
    respond_with(:admin , @<%= singular_table_name %>)
  end

  # GET <%= route_url %>/1/edit
  def edit
    @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
  end

  # POST <%= route_url %>
  # POST <%= route_url %>.xml
  def create
    @<%= singular_table_name %> = <%= orm_class.build(class_name, "params[:#{singular_table_name}]") %>
    @<%= orm_instance.save %>
    respond_with(:admin,@<%= singular_table_name %>)
  end

  # PUT <%= route_url %>/1
  # PUT <%= route_url %>/1.xml
  def update
    @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
    @<%= orm_instance.update_attributes("params[:#{singular_table_name}]") %>
    respond_with(:admin,  @<%= singular_table_name %>)
  end

  # DELETE <%= route_url %>/1
  # DELETE <%= route_url %>/1.xml
  def destroy
    @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
    @<%= orm_instance.destroy %>
    respond_with(:admin ,@<%= singular_table_name %>, :notice => "Successfully destroyed <%= singular_table_name %>")
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cable-0.9.17 lib/generators/cable/resource/templates/controller.rb
cable-0.9.16 lib/generators/cable/resource/templates/controller.rb
cable-0.9.15 lib/generators/cable/resource/templates/controller.rb
cable-0.9.14 lib/generators/cable/resource/templates/controller.rb
cable-0.9.13 lib/generators/cable/resource/templates/controller.rb
cable-0.9.12 lib/generators/cable/resource/templates/controller.rb
cable-0.9.11 lib/generators/cable/resource/templates/controller.rb
cable-0.9.10 lib/generators/cable/resource/templates/controller.rb
cable-0.9.9 lib/generators/cable/resource/templates/controller.rb
cable-0.9.8 lib/generators/cable/resource/templates/controller.rb