Scaffolding plugin
Plugin details
Documentation
Install the plugin:
ruby script/plugin install http://dev.rubyonrails.org/svn/rails/plugins/scaffolding/
class WeblogController < ActionController::Base scaffold :entry end
This tiny piece of code will add all of the following methods to the controller:
class WeblogController < ActionController::Base verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def index list end def list @entries = Entry.find(:all) render_scaffold "list" end def show @entry = Entry.find(params[:id]) render_scaffold end def destroy Entry.find(params[:id]).destroy redirect_to :action => "list" end def new @entry = Entry.new render_scaffold end def create @entry = Entry.new(params[:entry]) if @entry.save flash[:notice] = "Entry was successfully created" redirect_to :action => "list" else render_scaffold('new') end end def edit @entry = Entry.find(params[:id]) render_scaffold end def update @entry = Entry.find(params[:id]) @entry.attributes = params[:entry] if @entry.save flash[:notice] = "Entry was successfully updated" redirect_to :action => "show", :id => @entry else render_scaffold('edit') end end end
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: maxim_kulkin, 8 months ago

