Sha256: 75671a8dfcfae6f9034560ac343146d07696c60b56881c6235d8964bb0c45e81

Contents?: true

Size: 1.6 KB

Versions: 8

Compression:

Stored size: 1.6 KB

Contents

class Admin::<%= class_name.pluralize %>Controller < AdminController
  
  respond_to :html, :xml, :json
  
  def index
    respond_with(:admin, @<%= plural_table_name %> = <%= orm_class.all(class_name) %>)
  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

8 entries across 8 versions & 1 rubygems

Version Path
cable-0.9.5 lib/generators/cable/resource/templates/controller.rb
cable-0.9.4 lib/generators/cable/resource/templates/controller.rb
cable-0.9.3 lib/generators/cable/resource/templates/controller.rb
cable-0.9.1 lib/generators/cable/resource/templates/controller.rb
cable-0.9.0 lib/generators/cable/resource/templates/controller.rb
cable-0.8.6 lib/generators/cable/resource/templates/controller.rb
cable-0.8.5 lib/generators/cable/resource/templates/controller.rb
cable-0.8.4 lib/generators/cable/resource/templates/controller.rb