Sha256: 0dac86030f5cc1b7cce054eb37006f48936e6367bae5e1b41884376e116e44e5

Contents?: true

Size: 1.69 KB

Versions: 30

Compression:

Stored size: 1.69 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 -%>
  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
  verify :method => :post, :only => [ :destroy<%= suffix %>, :create<%= suffix %>, :update<%= suffix %> ],
         :redirect_to => { :action => :list<%= suffix %> }

  def list<%= suffix %>
    @<%= singular_name %>_pages, @<%= plural_name %> = paginate :<%= plural_name %>, :per_page => 10
  end

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

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

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

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

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

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

Version data entries

30 entries across 30 versions & 5 rubygems

Version Path
jstorimer-deep-test-2.0.0 sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb
jstorimer-deep-test-1.4.0 sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb
jstorimer-deep-test-1.3.0 sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb
jstorimer-deep-test-1.2.0 sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb
jstorimer-deep-test-1.1.0 sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb
jstorimer-deep-test-1.0.0 sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb
jstorimer-deep-test-0.2.0 sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb
jstorimer-deep-test-0.1.0 sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb
persia_generator-0.1.0 templates/controller.rb
radiant-0.6.1 vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb
radiant-0.6.0 vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb
radiant-0.6.3 vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb
radiant-0.6.2 vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb
radiant-0.6.4 vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb
rails-1.1.0 lib/rails_generator/generators/components/scaffold/templates/controller.rb
rails-1.1.1 lib/rails_generator/generators/components/scaffold/templates/controller.rb
rails-1.1.5 lib/rails_generator/generators/components/scaffold/templates/controller.rb
rails-1.1.2 lib/rails_generator/generators/components/scaffold/templates/controller.rb
rails-1.1.3 lib/rails_generator/generators/components/scaffold/templates/controller.rb
rails-1.1.4 lib/rails_generator/generators/components/scaffold/templates/controller.rb