Sha256: 842459274475df287a1d4a9c8ccad62c01eb04602e0db5398926982e43ec0efd
Contents?: true
Size: 1.4 KB
Versions: 2
Compression:
Stored size: 1.4 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 %> = <%= model_name %>.find_all 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails-0.11.1 | lib/rails_generator/generators/components/scaffold/templates/controller.rb |
rails-0.11.0 | lib/rails_generator/generators/components/scaffold/templates/controller.rb |