Sha256: 9afec92f18282068c9a1b254c35383abd595c49890ecb085dd4819ac8136c27d
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
class <%= controller_class_name %>Controller < ApplicationController def index @<%= table_name %> = <%= class_name %>.find(:all) end def show @<%= file_name %> = <%= class_name %>.find(params[:id]) end def new @<%= file_name %> = <%= class_name %>.new end def edit @<%= file_name %> = <%= class_name %>.find(params[:id]) end def create @<%= file_name %> = <%= class_name %>.create(params[:<%= file_name %>]) if @<%= file_name %>.save flash[:notice] = '<%= singular_name.humanize %> was successfully created.' redirect_to(@<%= file_name %>) else render :action => "new" end end def update @<%= file_name %> = <%= class_name %>.find(params[:id]) if @<%= file_name %>.update_attributes(params[:<%= file_name %>]) flash[:notice] = '<%= singular_name.humanize %> was successfully updated.' redirect_to(@<%= file_name %>) else render :action => "edit" end end def destroy @<%= file_name %> = <%= class_name %>.find(params[:id]) @<%= file_name %>.destroy flash[:success] = "User @<%= file_name %> was removed" redirect_to(<%= table_name %>_url) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stefanpenner-my_scaffold-1.4.1 | generators/my_scaffold/templates/controller.rb |