Sha256: 1a0a51261375ce5a81925aa356c8b13f37ad2d01f00e182690522fe8ba55c4d2

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 KB

Contents

class <%= @controller_class_name %>Controller < ApplicationController
<% unless suffix -%>
  def index
    list
    render_action 'list'
  end
<% end -%>

<% for action in unscaffolded_actions -%>
  def <%= action %><%= suffix %>
  end

<% end -%>
  def list<%= suffix %>
    @<%= plural_name %> = <%= class_name %>.find_all
  end

  def show<%= suffix %>
    @<%= singular_name %> = <%= class_name %>.find(@params['id'])
  end

  def new<%= suffix %>
    @<%= singular_name %> = <%= class_name %>.new
  end

  def create<%= suffix %>
    @<%= singular_name %> = <%= class_name %>.new(@params['<%= singular_name %>'])
    if @<%= singular_name %>.save
      flash['notice'] = '<%= class_name %> was successfully created.'
      redirect_to :action => 'list<%= suffix %>'
    else
      render_action 'new<%= suffix %>'
    end
  end

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

  def update
    @<%= singular_name %> = <%= class_name %>.find(@params['<%= singular_name %>']['id'])
    if @<%= singular_name %>.update_attributes(@params['<%= singular_name %>'])
      flash['notice'] = '<%= class_name %> was successfully updated.'
      redirect_to :action => 'show<%= suffix %>', :id => @<%= singular_name %>.id
    else
      render_action 'edit<%= suffix %>'
    end
  end

  def destroy<%= suffix %>
    <%= class_name %>.find(@params['id']).destroy
    redirect_to :action => 'list<%= suffix %>'
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
devise_sociable-0.1.0 vendor/bundle/gems/rails-0.9.5/generators/scaffold/templates/controller.rb
rails-0.9.4 generators/scaffold/templates/controller.rb
rails-0.9.4.1 generators/scaffold/templates/controller.rb
rails-0.9.5 generators/scaffold/templates/controller.rb