aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-09-09 22:26:36 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-09-09 22:26:36 +0000
commitc70a7311159b813facec3b76978086f8106377cc (patch)
tree4c0d2a2bcc9039e3fd7e170a2dad756bdcc4992a
parent6b0a6472365a7b9c3883d2de3ae19b49e77c847f (diff)
downloadrails-c70a7311159b813facec3b76978086f8106377cc.tar.gz
rails-c70a7311159b813facec3b76978086f8106377cc.tar.bz2
rails-c70a7311159b813facec3b76978086f8106377cc.zip
Removed ActionController::Base.scaffold -- it went through the whole idea of scaffolding (card board walls you remove and tweak one by one). Use the scaffold generator instead (it does resources too now!) [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7429 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/scaffolding.rb191
-rw-r--r--actionpack/lib/action_controller/templates/scaffolds/edit.erb7
-rw-r--r--actionpack/lib/action_controller/templates/scaffolds/edit.rhtml0
-rw-r--r--actionpack/lib/action_controller/templates/scaffolds/layout.erb69
-rw-r--r--actionpack/lib/action_controller/templates/scaffolds/layout.rhtml0
-rw-r--r--actionpack/lib/action_controller/templates/scaffolds/list.erb27
-rw-r--r--actionpack/lib/action_controller/templates/scaffolds/list.rhtml0
-rw-r--r--actionpack/lib/action_controller/templates/scaffolds/new.erb6
-rw-r--r--actionpack/lib/action_controller/templates/scaffolds/new.rhtml0
-rw-r--r--actionpack/lib/action_controller/templates/scaffolds/show.erb9
-rw-r--r--actionpack/lib/action_controller/templates/scaffolds/show.rhtml0
12 files changed, 2 insertions, 309 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index a7b7f1f7f3..8c5f49fec1 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Removed ActionController::Base.scaffold -- it went through the whole idea of scaffolding (card board walls you remove and tweak one by one). Use the scaffold generator instead (it does resources too now!) [DHH]
+
* Optimise named route generation when using positional arguments. [Koz]
This change delivers significant performance benefits for the most
diff --git a/actionpack/lib/action_controller/scaffolding.rb b/actionpack/lib/action_controller/scaffolding.rb
deleted file mode 100644
index 327e8b0912..0000000000
--- a/actionpack/lib/action_controller/scaffolding.rb
+++ /dev/null
@@ -1,191 +0,0 @@
-module ActionController
- module Scaffolding # :nodoc:
- def self.included(base)
- base.extend(ClassMethods)
- end
-
- # Scaffolding is a way to quickly put an Active Record class online by providing a series of standardized actions
- # for listing, showing, creating, updating, and destroying objects of the class. These standardized actions come
- # with both controller logic and default templates that through introspection already know which fields to display
- # and which input types to use. Example:
- #
- # 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
- #
- # The <tt>render_scaffold</tt> method will first check to see if you've made your own template (like "weblog/show.erb" for
- # the show action) and if not, then render the generic template for that action. This gives you the possibility of using the
- # scaffold while you're building your specific application. Start out with a totally generic setup, then replace one template
- # and one action at a time while relying on the rest of the scaffolded templates and actions.
- module ClassMethods
- # Adds a swath of generic CRUD actions to the controller. The +model_id+ is automatically converted into a class name unless
- # one is specifically provide through <tt>options[:class_name]</tt>. So <tt>scaffold :post</tt> would use Post as the class
- # and @post/@posts for the instance variables.
- #
- # It's possible to use more than one scaffold in a single controller by specifying <tt>options[:suffix] = true</tt>. This will
- # make <tt>scaffold :post, :suffix => true</tt> use method names like list_post, show_post, and create_post
- # instead of just list, show, and post. If suffix is used, then no index method is added.
- def scaffold(model_id, options = {})
- options.assert_valid_keys(:class_name, :suffix)
-
- singular_name = model_id.to_s
- class_name = options[:class_name] || singular_name.camelize
- plural_name = singular_name.pluralize
- suffix = options[:suffix] ? "_#{singular_name}" : ""
-
- unless options[:suffix]
- module_eval <<-"end_eval", __FILE__, __LINE__
- def index
- list
- end
- end_eval
- end
-
- module_eval <<-"end_eval", __FILE__, __LINE__
-
- 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
- render#{suffix}_scaffold "list#{suffix}"
- end
-
- def show#{suffix}
- @#{singular_name} = #{class_name}.find(params[:id])
- render#{suffix}_scaffold
- end
-
- def destroy#{suffix}
- #{class_name}.find(params[:id]).destroy
- redirect_to :action => "list#{suffix}"
- end
-
- def new#{suffix}
- @#{singular_name} = #{class_name}.new
- render#{suffix}_scaffold
- 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#{suffix}_scaffold('new')
- end
- end
-
- def edit#{suffix}
- @#{singular_name} = #{class_name}.find(params[:id])
- render#{suffix}_scaffold
- end
-
- def update#{suffix}
- @#{singular_name} = #{class_name}.find(params[:id])
- @#{singular_name}.attributes = params[:#{singular_name}]
-
- if @#{singular_name}.save
- flash[:notice] = "#{class_name} was successfully updated"
- redirect_to :action => "show#{suffix}", :id => @#{singular_name}
- else
- render#{suffix}_scaffold('edit')
- end
- end
-
- private
- def render#{suffix}_scaffold(action=nil)
- action ||= caller_method_name(caller)
- # logger.info ("testing template:" + "\#{self.class.controller_path}/\#{action}") if logger
-
- if template_exists?("\#{self.class.controller_path}/\#{action}")
- render :action => action
- else
- @scaffold_class = #{class_name}
- @scaffold_singular_name, @scaffold_plural_name = "#{singular_name}", "#{plural_name}"
- @scaffold_suffix = "#{suffix}"
- add_instance_variables_to_assigns
-
- @template.instance_variable_set("@content_for_layout", @template.render_file(scaffold_path(action.sub(/#{suffix}$/, "")), false))
-
- if !active_layout.nil?
- render :file => active_layout, :use_full_path => true
- else
- render :file => scaffold_path('layout')
- end
- end
- end
-
- def scaffold_path(template_name)
- File.dirname(__FILE__) + "/templates/scaffolds/" + template_name + ".erb"
- end
-
- def caller_method_name(caller)
- caller.first.scan(/`(.*)'/).first.first # ' ruby-mode
- end
- end_eval
- end
-
- deprecate :scaffold => 'Controller scaffolding will be moved to a plugin in Rails 2.0. Switch to the generator or `script/plugin install scaffolding`'
- end
- end
-end
diff --git a/actionpack/lib/action_controller/templates/scaffolds/edit.erb b/actionpack/lib/action_controller/templates/scaffolds/edit.erb
deleted file mode 100644
index 63dff602a1..0000000000
--- a/actionpack/lib/action_controller/templates/scaffolds/edit.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-<h1>Editing <%= @scaffold_singular_name %></h1>
-
-<%= error_messages_for(@scaffold_singular_name) %>
-<%= form(@scaffold_singular_name, :action => "update#{@scaffold_suffix}") %>
-
-<%= link_to "Show", :action => "show#{@scaffold_suffix}", :id => instance_variable_get("@#{@scaffold_singular_name}") %> |
-<%= link_to "Back", :action => "list#{@scaffold_suffix}" %>
diff --git a/actionpack/lib/action_controller/templates/scaffolds/edit.rhtml b/actionpack/lib/action_controller/templates/scaffolds/edit.rhtml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/actionpack/lib/action_controller/templates/scaffolds/edit.rhtml
+++ /dev/null
diff --git a/actionpack/lib/action_controller/templates/scaffolds/layout.erb b/actionpack/lib/action_controller/templates/scaffolds/layout.erb
deleted file mode 100644
index 759781e0e7..0000000000
--- a/actionpack/lib/action_controller/templates/scaffolds/layout.erb
+++ /dev/null
@@ -1,69 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
- <title>Scaffolding</title>
- <style>
- body { background-color: #fff; color: #333; }
-
- body, p, ol, ul, td {
- font-family: verdana, arial, helvetica, sans-serif;
- font-size: 13px;
- line-height: 18px;
- }
-
- pre {
- background-color: #eee;
- padding: 10px;
- font-size: 11px;
- }
-
- a { color: #000; }
- a:visited { color: #666; }
- a:hover { color: #fff; background-color:#000; }
-
- .fieldWithErrors {
- padding: 2px;
- background-color: red;
- display: table;
- }
-
- #errorExplanation {
- width: 400px;
- border: 2px solid red;
- padding: 7px;
- padding-bottom: 12px;
- margin-bottom: 20px;
- background-color: #f0f0f0;
- }
-
- #errorExplanation h2 {
- text-align: left;
- font-weight: bold;
- padding: 5px 5px 5px 15px;
- font-size: 12px;
- margin: -7px;
- background-color: #c00;
- color: #fff;
- }
-
- #errorExplanation p {
- color: #333;
- margin-bottom: 0;
- padding: 5px;
- }
-
- #errorExplanation ul li {
- font-size: 12px;
- list-style: square;
- }
- </style>
-</head>
-<body>
-
-<p style="color: green"><%= flash[:notice] %></p>
-
-<%= yield %>
-
-</body>
-</html>
diff --git a/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml b/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml
+++ /dev/null
diff --git a/actionpack/lib/action_controller/templates/scaffolds/list.erb b/actionpack/lib/action_controller/templates/scaffolds/list.erb
deleted file mode 100644
index fea23dc66f..0000000000
--- a/actionpack/lib/action_controller/templates/scaffolds/list.erb
+++ /dev/null
@@ -1,27 +0,0 @@
-<h1>Listing <%= @scaffold_plural_name %></h1>
-
-<table>
- <tr>
- <% for column in @scaffold_class.content_columns %>
- <th><%= column.human_name %></th>
- <% end %>
- </tr>
-
-<% for entry in instance_variable_get("@#{@scaffold_plural_name}") %>
- <tr>
- <% for column in @scaffold_class.content_columns %>
- <td><%= entry.send(column.name) %></td>
- <% end %>
- <td><%= link_to "Show", :action => "show#{@scaffold_suffix}", :id => entry %></td>
- <td><%= link_to "Edit", :action => "edit#{@scaffold_suffix}", :id => entry %></td>
- <td><%= link_to "Destroy", {:action => "destroy#{@scaffold_suffix}", :id => entry}, { :confirm => "Are you sure?", :method => :post } %></td>
- </tr>
-<% end %>
-</table>
-
-<%= link_to "Previous page", { :page => instance_variable_get("@#{@scaffold_singular_name}_pages").current.previous } if instance_variable_get("@#{@scaffold_singular_name}_pages").current.previous %>
-<%= link_to "Next page", { :page => instance_variable_get("@#{@scaffold_singular_name}_pages").current.next } if instance_variable_get("@#{@scaffold_singular_name}_pages").current.next %>
-
-<br />
-
-<%= link_to "New #{@scaffold_singular_name}", :action => "new#{@scaffold_suffix}" %>
diff --git a/actionpack/lib/action_controller/templates/scaffolds/list.rhtml b/actionpack/lib/action_controller/templates/scaffolds/list.rhtml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/actionpack/lib/action_controller/templates/scaffolds/list.rhtml
+++ /dev/null
diff --git a/actionpack/lib/action_controller/templates/scaffolds/new.erb b/actionpack/lib/action_controller/templates/scaffolds/new.erb
deleted file mode 100644
index 66f6626f4e..0000000000
--- a/actionpack/lib/action_controller/templates/scaffolds/new.erb
+++ /dev/null
@@ -1,6 +0,0 @@
-<h1>New <%= @scaffold_singular_name %></h1>
-
-<%= error_messages_for(@scaffold_singular_name) %>
-<%= form(@scaffold_singular_name, :action => "create#{@scaffold_suffix}") %>
-
-<%= link_to "Back", :action => "list#{@scaffold_suffix}" %>
diff --git a/actionpack/lib/action_controller/templates/scaffolds/new.rhtml b/actionpack/lib/action_controller/templates/scaffolds/new.rhtml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/actionpack/lib/action_controller/templates/scaffolds/new.rhtml
+++ /dev/null
diff --git a/actionpack/lib/action_controller/templates/scaffolds/show.erb b/actionpack/lib/action_controller/templates/scaffolds/show.erb
deleted file mode 100644
index 46cdfdb493..0000000000
--- a/actionpack/lib/action_controller/templates/scaffolds/show.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-<% for column in @scaffold_class.content_columns %>
- <p>
- <b><%= column.human_name %>:</b>
- <%= instance_variable_get("@#{@scaffold_singular_name}").send(column.name) %>
- </p>
-<% end %>
-
-<%= link_to "Edit", :action => "edit#{@scaffold_suffix}", :id => instance_variable_get("@#{@scaffold_singular_name}") %> |
-<%= link_to "Back", :action => "list#{@scaffold_suffix}" %>
diff --git a/actionpack/lib/action_controller/templates/scaffolds/show.rhtml b/actionpack/lib/action_controller/templates/scaffolds/show.rhtml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/actionpack/lib/action_controller/templates/scaffolds/show.rhtml
+++ /dev/null