Sha256: ef6e25a7cc0a3900d8b1eed959f95bc39d266093570f8ccab7e7072e22daa73d
Contents?: true
Size: 1.43 KB
Versions: 2
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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails-0.10.1 | lib/rails_generator/generators/components/scaffold/templates/controller.rb |
rails-0.10.0 | lib/rails_generator/generators/components/scaffold/templates/controller.rb |