Sha256: 37fd7fb7de6deaa47244fab9241da8a658780bd0ede4418f7d9e2680dd86574c

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

class <%= @name_plural_camel %>Controller < Mack::Controller::Base

  # GET /<%= @name_plural %>
  def index
    @<%= @name_plural %> = <%= @name_singular_camel %>.find(:all)
  end

  # GET /<%= @name_plural %>/1
  def show
    @<%= @name_singular %> = <%= @name_singular_camel %>.find(params(:id))
  end

  # GET /<%= @name_plural %>/new
  def new
    @<%= @name_singular %> = <%= @name_singular_camel %>.new
  end

  # GET /<%= @name_plural %>/1/edit
  def edit
    @<%= @name_singular %> = <%= @name_singular_camel %>.find(params(:id))
  end

  # POST /<%= @name_plural %>
  def create
    @<%= @name_singular %> = <%= @name_singular_camel %>.new(params(:<%= @name_singular %>))
    if @<%= @name_singular %>.save
      redirect_to(<%= @name_plural %>_show_url(:id => @<%= @name_singular %>.id))
    else
      render(:action => "new")
    end
  end

  # PUT /<%= @name_plural %>/1
  def update
    @<%= @name_singular %> = <%= @name_singular_camel %>.find(params(:id))
    if @<%= @name_singular %>.update_attributes(params(:<%= @name_singular %>))
      redirect_to(<%= @name_plural %>_show_url(:id => @<%= @name_singular %>.id))
    else
      render(:action => "edit")
    end
  end

  # DELETE /<%= @name_plural %>/1
  def delete
    @<%= @name_singular %> = <%= @name_singular_camel %>.find(params(:id))
    @<%= @name_singular %>.destroy<%= app_config.orm == "data_mapper" ? "!" : "" %>
    redirect_to(<%= @name_plural %>_index_url)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mack-0.4.5 lib/generators/scaffold_generator/templates/generic/app/controllers/controller.rb.template
mack-0.4.6 lib/generators/scaffold_generator/templates/generic/app/controllers/controller.rb.template
mack-0.4.7 lib/generators/scaffold_generator/templates/generic/app/controllers/controller.rb.template