Sha256: 9ab6c0ba91e095aaad2e78e2f7683914549610d9162081803eff33e161822af2

Contents?: true

Size: 1.48 KB

Versions: 21

Compression:

Stored size: 1.48 KB

Contents

Admin.controllers :<%= @orm.name_plural %> do

  get :index do
    @<%= @orm.name_plural %> = <%= @orm.all %>
    render '<%= @orm.name_plural %>/index'
  end

  get :new do
    @<%= @orm.name_singular %> = <%= @orm.build %>
    render '<%= @orm.name_plural %>/new'
  end

  post :create do
    @<%= @orm.name_singular %> = <%= @orm.build("params[:#{@orm.name_singular}]") %>
    if <%= @orm.save %>
      flash[:notice] = '<%= @orm.klass_name %> was successfully created.'
      redirect url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular%>.id)
    else
      render '<%= @orm.name_plural %>/new'
    end
  end

  get :edit, :with => :id do
    @<%= @orm.name_singular %> = <%= @orm.find("params[:id]") %>
    render '<%= @orm.name_plural %>/edit'
  end

  put :update, :with => :id do
    @<%= @orm.name_singular %> = <%= @orm.find("params[:id]") %>
    if <%= @orm.update_attributes("params[:#{@orm.name_singular}]") %>
      flash[:notice] = '<%= @orm.klass_name %> was successfully updated.'
      redirect url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular %>.id)
    else
      render '<%= @orm.name_plural %>/edit'
    end
  end

  delete :destroy, :with => :id do
    <%= @orm.name_singular %> = <%= @orm.find("params[:id]") %>
    if <%= @orm.destroy %>
      flash[:notice] = '<%= @orm.klass_name %> was successfully destroyed.'
    else
      flash[:error] = 'Impossible destroy <%= @orm.klass_name %>!'
    end
    redirect url(:<%= @orm.name_plural %>, :index)
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
padrino-admin-0.10.0 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.29 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.28 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.27 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.26 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.24 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.25 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.23 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.22 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.21 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.20 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.19 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.18 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.17 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.16 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.15 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.14 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.13 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.12 lib/padrino-admin/generators/templates/page/controller.rb.tt
padrino-admin-0.9.11 lib/padrino-admin/generators/templates/page/controller.rb.tt