aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG4
-rw-r--r--actionpack/lib/action_controller/assertions/dom_assertions.rb4
-rw-r--r--actionpack/lib/action_controller/assertions/model_assertions.rb2
-rw-r--r--actionpack/lib/action_controller/assertions/response_assertions.rb2
-rw-r--r--actionpack/lib/action_controller/assertions/routing_assertions.rb1
-rw-r--r--actionpack/lib/action_controller/mime_types.rb3
-rw-r--r--actionpack/lib/action_controller/url_rewriter.rb2
-rw-r--r--actionpack/lib/action_view/base.rb44
-rw-r--r--actionpack/lib/action_view/compiled_templates.rb4
-rw-r--r--actionpack/lib/action_view/helpers/active_record_helper.rb36
-rw-r--r--actionpack/lib/action_view/helpers/debug_helper.rb10
-rw-r--r--activerecord/CHANGELOG2
-rw-r--r--activerecord/lib/active_record/acts/list.rb9
-rw-r--r--activerecord/lib/active_record/acts/tree.rb7
-rwxr-xr-xactiverecord/lib/active_record/associations.rb9
-rwxr-xr-xactiverecord/lib/active_record/base.rb3
-rw-r--r--activerecord/lib/active_record/calculations.rb4
-rw-r--r--activerecord/lib/active_record/deprecated_finders.rb6
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/initializer.rb2
-rw-r--r--railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb2
21 files changed, 108 insertions, 50 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index c9a5aea0b2..b6ee5b6e87 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,9 @@
*SVN*
+* Cleaned up, corrected, and mildly expanded ActionPack documentation. Closes #7190 [jeremymcanally]
+
+* Small collection of ActionController documentation cleanups. Closes #7319 [jeremymcanally]
+
* Make sure the route expiry hash is constructed by comparing the to_param-ized values of each hash. [Jamis Buck]
* Allow configuration of the default action cache path for #caches_action calls. [Rick Olson]
diff --git a/actionpack/lib/action_controller/assertions/dom_assertions.rb b/actionpack/lib/action_controller/assertions/dom_assertions.rb
index d1eea59ea0..355080fe54 100644
--- a/actionpack/lib/action_controller/assertions/dom_assertions.rb
+++ b/actionpack/lib/action_controller/assertions/dom_assertions.rb
@@ -1,7 +1,7 @@
module ActionController
module Assertions
module DomAssertions
- # test 2 html strings to be equivalent, i.e. identical up to reordering of attributes
+ # Test two HTML strings for equivalency (e.g., identical up to reordering of attributes)
def assert_dom_equal(expected, actual, message="")
clean_backtrace do
expected_dom = HTML::Document.new(expected).root
@@ -11,7 +11,7 @@ module ActionController
end
end
- # negated form of +assert_dom_equivalent+
+ # The negated form of +assert_dom_equivalent+.
def assert_dom_not_equal(expected, actual, message="")
clean_backtrace do
expected_dom = HTML::Document.new(expected).root
diff --git a/actionpack/lib/action_controller/assertions/model_assertions.rb b/actionpack/lib/action_controller/assertions/model_assertions.rb
index a9bcd7db9a..5fc5c81cb7 100644
--- a/actionpack/lib/action_controller/assertions/model_assertions.rb
+++ b/actionpack/lib/action_controller/assertions/model_assertions.rb
@@ -1,7 +1,7 @@
module ActionController
module Assertions
module ModelAssertions
- # ensures that the passed record is valid by active record standards. returns the error messages if not
+ # Ensures that the passed record is valid by ActiveRecord standards and returns any error messages if it is not.
def assert_valid(record)
clean_backtrace do
assert record.valid?, record.errors.full_messages.join("\n")
diff --git a/actionpack/lib/action_controller/assertions/response_assertions.rb b/actionpack/lib/action_controller/assertions/response_assertions.rb
index cf30569f36..de7efd0ac9 100644
--- a/actionpack/lib/action_controller/assertions/response_assertions.rb
+++ b/actionpack/lib/action_controller/assertions/response_assertions.rb
@@ -119,6 +119,7 @@ module ActionController
end
private
+ # Recognizes the route for a given path.
def recognized_request_for(path, request_method = nil)
path = "/#{path}" unless path.first == '/'
@@ -131,6 +132,7 @@ module ActionController
request
end
+ # Proxy to to_param if the object will respond to it.
def parameterize(value)
value.respond_to?(:to_param) ? value.to_param : value
end
diff --git a/actionpack/lib/action_controller/assertions/routing_assertions.rb b/actionpack/lib/action_controller/assertions/routing_assertions.rb
index 11a649c49a..6cd4d48b9e 100644
--- a/actionpack/lib/action_controller/assertions/routing_assertions.rb
+++ b/actionpack/lib/action_controller/assertions/routing_assertions.rb
@@ -82,6 +82,7 @@ module ActionController
end
private
+ # Recognizes the route for a given path.
def recognized_request_for(path, request_method = nil)
path = "/#{path}" unless path.first == '/'
diff --git a/actionpack/lib/action_controller/mime_types.rb b/actionpack/lib/action_controller/mime_types.rb
index 66a3133c4f..8273a2403b 100644
--- a/actionpack/lib/action_controller/mime_types.rb
+++ b/actionpack/lib/action_controller/mime_types.rb
@@ -1,3 +1,6 @@
+# Build list of Mime types for HTTP responses
+# http://www.iana.org/assignments/media-types/
+
Mime::Type.register "*/*", :all
Mime::Type.register "text/plain", :text, [], %w(txt)
Mime::Type.register "text/html", :html, %w( application/xhtml+xml ), %w( xhtml )
diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb
index 66b77e405f..88c7afff41 100644
--- a/actionpack/lib/action_controller/url_rewriter.rb
+++ b/actionpack/lib/action_controller/url_rewriter.rb
@@ -75,6 +75,7 @@ module ActionController
alias_method :to_s, :to_str
private
+ # Given a path and options, returns a rewritten URL string
def rewrite_url(options)
rewritten_url = ""
@@ -94,6 +95,7 @@ module ActionController
rewritten_url
end
+ # Given a Hash of options, generates a route
def rewrite_path(options)
options = options.symbolize_keys
options.update(options[:params].symbolize_keys) if options[:params]
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 9956e0fe28..5d52eeaef9 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -148,7 +148,7 @@ module ActionView #:nodoc:
#
# This refreshes the sidebar, removes a person element and highlights the user list.
#
- # See the ActionView::Helpers::PrototypeHelper::JavaScriptGenerator documentation for more details.
+ # See the ActionView::Helpers::PrototypeHelper::GeneratorMethods documentation for more details.
class Base
include ERB::Util
@@ -160,7 +160,7 @@ module ActionView #:nodoc:
attr_internal :cookies, :flash, :headers, :params, :request, :response, :session
# Specify trim mode for the ERB compiler. Defaults to '-'.
- # See ERB documentation for suitable values.
+ # See ERb documentation for suitable values.
@@erb_trim_mode = '-'
cattr_accessor :erb_trim_mode
@@ -194,17 +194,17 @@ module ActionView #:nodoc:
end
include CompiledTemplates
- # maps inline templates to their method names
+ # Maps inline templates to their method names
@@method_names = {}
- # map method names to their compile time
+ # Map method names to their compile time
@@compile_time = {}
- # map method names to the names passed in local assigns so far
+ # Map method names to the names passed in local assigns so far
@@template_args = {}
- # count the number of inline templates
+ # Count the number of inline templates
@@inline_template_count = 0
- # maps template paths without extension to their file extension returned by pick_template_extension.
- # if for a given path, path.ext1 and path.ext2 exist on the file system, the order of extensions
- # used by pick_template_extension determines whether ext1 or ext2 will be stored
+ # Maps template paths without extension to their file extension returned by pick_template_extension.
+ # If for a given path, path.ext1 and path.ext2 exist on the file system, the order of extensions
+ # used by pick_template_extension determines whether ext1 or ext2 will be stored.
@@cached_template_extension = {}
class ObjectWrapper < Struct.new(:value) #:nodoc:
@@ -307,7 +307,6 @@ module ActionView #:nodoc:
# Render the provided template with the given local assigns. If the template has not been rendered with the provided
# local assigns yet, or if the template has been updated on disk, then the template will be compiled to a method.
#
-
# Either, but not both, of template and file_path may be nil. If file_path is given, the template
# will only be read if it has to be compiled.
#
@@ -384,6 +383,7 @@ module ActionView #:nodoc:
"#{base_path}/#{file_name}"
end
+ # Asserts the existence of a template.
def template_exists?(template_path, extension)
file_path = full_template_path(template_path, extension)
@@method_names.has_key?(file_path) || FileTest.exists?(file_path)
@@ -402,7 +402,8 @@ module ActionView #:nodoc:
def find_base_path_for(template_file_name)
@view_paths.find { |p| File.file?(File.join(p, template_file_name)) }
end
-
+
+ # Determines the template's file extension, such as rhtml, rxml, or rjs.
def find_template_extension_for(template_path)
if match = delegate_template_exists?(template_path)
match.first.to_sym
@@ -419,6 +420,7 @@ module ActionView #:nodoc:
File.read(template_path)
end
+ # Evaluate the local assigns and pushes them to the view.
def evaluate_assigns
unless @assigns_added
assign_variables_from_controller
@@ -430,6 +432,7 @@ module ActionView #:nodoc:
handler.new(self).render(template, local_assigns)
end
+ # Assigns instance variables from the controller to the view.
def assign_variables_from_controller
@assigns.each { |key, value| instance_variable_set("@#{key}", value) }
end
@@ -441,10 +444,10 @@ module ActionView #:nodoc:
((args = @@template_args[render_symbol]) && local_assigns.all? { |k,_| args.has_key?(k) })
end
- # Check whether compilation is necessary.
- # Compile if the inline template or file has not been compiled yet.
- # Or if local_assigns has a new key, which isn't supported by the compiled code yet.
- # Or if the file has changed on disk and checking file mods hasn't been disabled.
+ # Method to check whether template compilation is necessary.
+ # The template will be compiled if the inline template or file has not been compiled yet,
+ # if local_assigns has a new key, which isn't supported by the compiled code yet,
+ # or if the file has changed on disk and checking file mods hasn't been disabled.
def compile_template?(template, file_name, local_assigns)
method_key = file_name || template
render_symbol = @@method_names[method_key]
@@ -458,14 +461,14 @@ module ActionView #:nodoc:
end
end
- # handles checking if template changed since last compile, isolated so that templates
- # not stored on the file system can hook and extend appropriately
+ # Method to handle checking a whether a template has changed since last compile; isolated so that templates
+ # not stored on the file system can hook and extend appropriately.
def template_changed_since?(file_name, compile_time)
compile_time < File.mtime(file_name) ||
(File.symlink?(file_name) && (compile_time < File.lstat(file_name).mtime))
end
- # Create source code for given template
+ # Method to create the source code for a given template.
def create_template_source(extension, template, render_symbol, locals)
if template_requires_setup?(extension)
body = case extension.to_sym
@@ -493,11 +496,11 @@ module ActionView #:nodoc:
"def #{render_symbol}(local_assigns)\n#{locals_code}#{body}\nend"
end
- def template_requires_setup?(extension)
+ def template_requires_setup?(extension) #:nodoc:
templates_requiring_setup.include? extension.to_s
end
- def templates_requiring_setup
+ def templates_requiring_setup #:nodoc:
%w(builder rxml rjs)
end
@@ -521,6 +524,7 @@ module ActionView #:nodoc:
end
end
+ # Compile and evaluate the template's code
def compile_template(extension, template, file_name, local_assigns)
render_symbol = assign_method_name(extension, template, file_name)
render_source = create_template_source(extension, template, render_symbol, local_assigns.keys)
diff --git a/actionpack/lib/action_view/compiled_templates.rb b/actionpack/lib/action_view/compiled_templates.rb
index deb730f4da..73cce12e0d 100644
--- a/actionpack/lib/action_view/compiled_templates.rb
+++ b/actionpack/lib/action_view/compiled_templates.rb
@@ -3,14 +3,14 @@ module ActionView
# CompiledTemplates modules hold methods that have been compiled.
# Templates are compiled into these methods so that they do not need to be
- # re-read and re-parsed each request.
+ # read and parsed for each request.
#
# Each template may be compiled into one or more methods. Each method accepts a given
# set of parameters which is used to implement local assigns passing.
#
# To use a compiled template module, create a new instance and include it into the class
# in which you want the template to be rendered.
- class CompiledTemplates < Module #:nodoc:
+ class CompiledTemplates < Module
attr_reader :method_names
def initialize
diff --git a/actionpack/lib/action_view/helpers/active_record_helper.rb b/actionpack/lib/action_view/helpers/active_record_helper.rb
index dcaf54be46..97ddc41c7e 100644
--- a/actionpack/lib/action_view/helpers/active_record_helper.rb
+++ b/actionpack/lib/action_view/helpers/active_record_helper.rb
@@ -13,17 +13,18 @@ module ActionView
# is a great of making the record quickly available for editing, but likely to prove lackluster for a complicated real-world form.
# In that case, it's better to use the input method and the specialized form methods in link:classes/ActionView/Helpers/FormHelper.html
module ActiveRecordHelper
- # Returns a default input tag for the type of object returned by the method. Example
- # (title is a VARCHAR column and holds "Hello World"):
+ # Returns a default input tag for the type of object returned by the method. For example, let's say you have a model
+ # that has an attribute +title+ of type VARCHAR column, and this instance holds "Hello World":
# input("post", "title") =>
# <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />
def input(record_name, method, options = {})
InstanceTag.new(record_name, method, self).to_tag(options)
end
- # Returns an entire form with input tags and everything for a specified Active Record object. Example
- # (post is a new record that has a title using VARCHAR and a body using TEXT):
- # form("post") =>
+ # Returns an entire form with all needed input tags for a specified Active Record object. For example, let's say you
+ # have a table model <tt>Post</tt> with attributes named <tt>title</tt> of type <tt>VARCHAR</tt> and <tt>body</tt> of type <tt>TEXT</tt>:
+ # form("post")
+ # That line would yield a form like the following:
# <form action='/post/create' method='post'>
# <p>
# <label for="post_title">Title</label><br />
@@ -32,14 +33,13 @@ module ActionView
# <p>
# <label for="post_body">Body</label><br />
# <textarea cols="40" id="post_body" name="post[body]" rows="20">
- # Back to the hill and over it again!
# </textarea>
# </p>
# <input type='submit' value='Create' />
# </form>
#
# It's possible to specialize the form builder by using a different action name and by supplying another
- # block renderer. Example (entry is a new record that has a message attribute using VARCHAR):
+ # block renderer. For example, let's say you have a model <tt>Entry</tt> with an attribute <tt>message</tt> of type <tt>VARCHAR</tt>:
#
# form("entry", :action => "sign", :input_block =>
# Proc.new { |record, column| "#{column.human_name}: #{input(record, column.name)}<br />" }) =>
@@ -74,16 +74,16 @@ module ActionView
content_tag('form', contents, :action => action, :method => 'post', :enctype => options[:multipart] ? 'multipart/form-data': nil)
end
- # Returns a string containing the error message attached to the +method+ on the +object+, if one exists.
- # This error message is wrapped in a DIV tag, which can be specialized to include both a +prepend_text+ and +append_text+
- # to properly introduce the error and a +css_class+ to style it accordingly. Examples (post has an error message
- # "can't be empty" on the title attribute):
+ # Returns a string containing the error message attached to the +method+ on the +object+ if one exists.
+ # This error message is wrapped in a <tt>DIV</tt> tag, which can be extended to include a +prepend_text+ and/or +append_text+
+ # (to properly explain the error), and a +css_class+ to style it accordingly. As an example, let's say you have a model
+ # +post+ that has an error message on the +title+ attribute:
#
# <%= error_message_on "post", "title" %> =>
# <div class="formError">can't be empty</div>
#
- # <%= error_message_on "post", "title", "Title simply ", " (or it won't work)", "inputError" %> =>
- # <div class="inputError">Title simply can't be empty (or it won't work)</div>
+ # <%= error_message_on "post", "title", "Title simply ", " (or it won't work).", "inputError" %> =>
+ # <div class="inputError">Title simply can't be empty (or it won't work).</div>
def error_message_on(object, method, prepend_text = "", append_text = "", css_class = "formError")
if (obj = instance_variable_get("@#{object}")) && (errors = obj.errors.on(method))
content_tag("div", "#{prepend_text}#{errors.is_a?(Array) ? errors.first : errors}#{append_text}", :class => css_class)
@@ -92,11 +92,11 @@ module ActionView
end
end
- # Returns a string with a div containing all of the error messages for the objects located as instance variables by the names
+ # Returns a string with a <tt>DIV</tt> containing all of the error messages for the objects located as instance variables by the names
# given. If more than one object is specified, the errors for the objects are displayed in the order that the object names are
# provided.
#
- # This div can be tailored by the following options:
+ # This <tt>DIV</tt> can be tailored by the following options:
#
# * <tt>header_tag</tt> - Used for the header of the error div (default: h2)
# * <tt>id</tt> - The id of the error div (default: errorExplanation)
@@ -105,12 +105,12 @@ module ActionView
# any text that you prefer. If <tt>object_name</tt> is not set, the name of
# the first object will be used.
#
- # Specifying one object:
+ # To specify the display for one object, you simply provide its name as a parameter. For example, for the +User+ model:
#
# error_messages_for 'user'
#
- # Specifying more than one object (and using the name 'user' in the
- # header as the <tt>object_name</tt> instead of 'user_common'):
+ # To specify more than one object, you simply list them; optionally, you can add an extra +object_name+ parameter, which
+ # be the name in the header.
#
# error_messages_for 'user_common', 'user', :object_name => 'user'
#
diff --git a/actionpack/lib/action_view/helpers/debug_helper.rb b/actionpack/lib/action_view/helpers/debug_helper.rb
index 9e92813a18..ef089c1bad 100644
--- a/actionpack/lib/action_view/helpers/debug_helper.rb
+++ b/actionpack/lib/action_view/helpers/debug_helper.rb
@@ -3,6 +3,16 @@ module ActionView
# Provides a set of methods for making it easier to locate problems.
module DebugHelper
# Returns a <pre>-tag set with the +object+ dumped by YAML. Very readable way to inspect an object.
+ # my_hash = {'first' => 1, 'second' => 'two', 'third' => [1,2,3]}
+ # debug(my_hash)
+ # => <pre class='debug_dump'>---
+ # first: 1
+ # second: two
+ # third:
+ # - 1
+ # - 2
+ # - 3
+ # </pre>
def debug(object)
begin
Marshal::dump(object)
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 8245d18790..bc8cd0ba86 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Small additions and fixes for ActiveRecord documentation. Closes #7342 [jeremymcanally]
+
* Add helpful debugging info to the ActiveRecord::StatementInvalid exception in ActiveRecord::ConnectionAdapters::SqliteAdapter#table_structure. Closes #7925. [court3nay]
* SQLite: binary escaping works with $KCODE='u'. #7862 [tsuka]
diff --git a/activerecord/lib/active_record/acts/list.rb b/activerecord/lib/active_record/acts/list.rb
index 87bb1280e1..cacf6a81f6 100644
--- a/activerecord/lib/active_record/acts/list.rb
+++ b/activerecord/lib/active_record/acts/list.rb
@@ -74,6 +74,7 @@ module ActiveRecord
# lower in the list of all chapters. Likewise, <tt>chapter.first?</tt> would return true if that chapter is
# the first in the list of all chapters.
module InstanceMethods
+ # Insert the item at the given position (defaults to the top position of 1).
def insert_at(position = 1)
insert_at_position(position)
end
@@ -118,6 +119,7 @@ module ActiveRecord
end
end
+ # Removes the item from the list.
def remove_from_list
decrement_positions_on_lower_items if in_list?
end
@@ -162,6 +164,7 @@ module ActiveRecord
)
end
+ # Test if this record is in a list
def in_list?
!send(position_column).nil?
end
@@ -178,21 +181,26 @@ module ActiveRecord
# Overwrite this method to define the scope of the list changes
def scope_condition() "1" end
+ # Returns the bottom position number in the list.
+ # bottom_position_in_list # => 2
def bottom_position_in_list(except = nil)
item = bottom_item(except)
item ? item.send(position_column) : 0
end
+ # Returns the bottom item
def bottom_item(except = nil)
conditions = scope_condition
conditions = "#{conditions} AND #{self.class.primary_key} != #{except.id}" if except
acts_as_list_class.find(:first, :conditions => conditions, :order => "#{position_column} DESC")
end
+ # Forces item to assume the bottom position in the list.
def assume_bottom_position
update_attribute(position_column, bottom_position_in_list(self).to_i + 1)
end
+ # Forces item to assume the top position in the list.
def assume_top_position
update_attribute(position_column, 1)
end
@@ -227,6 +235,7 @@ module ActiveRecord
)
end
+ # Increments position (<tt>position_column</tt>) of all items in the list.
def increment_positions_on_all_items
acts_as_list_class.update_all(
"#{position_column} = (#{position_column} + 1)", "#{scope_condition}"
diff --git a/activerecord/lib/active_record/acts/tree.rb b/activerecord/lib/active_record/acts/tree.rb
index 44432d4741..b92587e521 100644
--- a/activerecord/lib/active_record/acts/tree.rb
+++ b/activerecord/lib/active_record/acts/tree.rb
@@ -70,16 +70,23 @@ module ActiveRecord
nodes
end
+ # Returns the root node of the tree.
def root
node = self
node = node.parent while node.parent
node
end
+ # Returns all siblings of the current node.
+ #
+ # subchild1.siblings # => [subchild2]
def siblings
self_and_siblings - [self]
end
+ # Returns all siblings and a reference to the current node.
+ #
+ # subchild1.self_and_siblings # => [subchild1, subchild2]
def self_and_siblings
parent ? parent.children : self.class.roots
end
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index c6eb4453ef..5393c3f91f 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -798,6 +798,7 @@ module ActiveRecord
deprecated_association_comparison_method(reflection.name, reflection.class_name)
end
+ # Create the callbacks to update counter cache
if options[:counter_cache]
cache_column = options[:counter_cache] == true ?
"#{self.to_s.underscore.pluralize}_count" :
@@ -935,6 +936,12 @@ module ActiveRecord
end
private
+ # Generate a join table name from two provided tables names.
+ # The order of names in join name is determined by lexical precedence.
+ # join_table_name("members", "clubs")
+ # => "clubs_members"
+ # join_table_name("members", "special_clubs")
+ # => "members_special_clubs"
def join_table_name(first_table_name, second_table_name)
if first_table_name < second_table_name
join_table = "#{first_table_name}_#{second_table_name}"
@@ -944,7 +951,7 @@ module ActiveRecord
table_name_prefix + join_table + table_name_suffix
end
-
+
def association_accessor_methods(reflection, association_proxy_class)
define_method(reflection.name) do |*params|
force_reload = params.first unless params.empty?
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index c680d7e304..aa90e8bcc2 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1229,6 +1229,9 @@ module ActiveRecord #:nodoc:
#
# It's even possible to use all the additional parameters to find. For example, the full interface for find_all_by_amount
# is actually find_all_by_amount(amount, options).
+ #
+ # This also enables you to initialize a record if it is not found, such as find_or_initialize_by_amount(amount)
+ # or find_or_create_by_user_and_password(user, password).
def method_missing(method_id, *arguments)
if match = /^find_(all_by|by)_([_a-zA-Z]\w*)$/.match(method_id.to_s)
finder, deprecated_finder = determine_finder(match), determine_deprecated_finder(match)
diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb
index 54bedf1294..a54ef468e0 100644
--- a/activerecord/lib/active_record/calculations.rb
+++ b/activerecord/lib/active_record/calculations.rb
@@ -246,8 +246,8 @@ module ActiveRecord
options.assert_valid_keys(CALCULATIONS_OPTIONS)
end
- # converts a given key to the value that the database adapter returns as
- #
+ # Converts a given key to the value that the database adapter returns as
+ # as a usable column name.
# users.id #=> users_id
# sum(id) #=> sum_id
# count(distinct users.id) #=> count_distinct_users_id
diff --git a/activerecord/lib/active_record/deprecated_finders.rb b/activerecord/lib/active_record/deprecated_finders.rb
index 4ab2dde5f0..d4dcaa3fa0 100644
--- a/activerecord/lib/active_record/deprecated_finders.rb
+++ b/activerecord/lib/active_record/deprecated_finders.rb
@@ -1,7 +1,7 @@
module ActiveRecord
class Base
class << self
- # This method is deprecated in favor of find with the :conditions option.
+ # DEPRECATION NOTICE: This method is deprecated in favor of find with the :conditions option.
#
# Works like find, but the record matching +id+ must also meet the +conditions+.
# +RecordNotFound+ is raised if no record can be found matching the +id+ or meeting the condition.
@@ -12,7 +12,7 @@ module ActiveRecord
end
deprecate :find_on_conditions => "use find(ids, :conditions => conditions)"
- # This method is deprecated in favor of find(:first, options).
+ # DEPRECATION NOTICE: This method is deprecated in favor of find(:first, options).
#
# Returns the object for the first record responding to the conditions in +conditions+,
# such as "group = 'master'". If more than one record is returned from the query, it's the first that'll
@@ -24,7 +24,7 @@ module ActiveRecord
end
deprecate :find_first => "use find(:first, ...)"
- # This method is deprecated in favor of find(:all, options).
+ # DEPRECATION NOTICE: This method is deprecated in favor of find(:all, options).
#
# Returns an array of all the objects that could be instantiated from the associated
# table in the database. The +conditions+ can be used to narrow the selection of objects (WHERE-part),
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 9eff591e53..73378b9c4e 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Give generate scaffold a more descriptive database message. Closes #7316 [jeremymcanally]
+
* Canonicalize RAILS_ROOT by using File.expand_path on Windows, which doesn't have to worry about symlinks, and Pathname#realpath elsewhere, which respects symlinks in relative paths but is incompatible with Windows. #6755 [Jeremy Kemper, trevor]
* Deprecation: remove components from controller paths. [Jeremy Kemper]
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index 15ae80f1cf..4f09dd45a3 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -205,7 +205,9 @@ module Rails
silence_warnings do
config = configuration
constants = self.class.constants
+
eval(IO.read(configuration.environment_path), binding, configuration.environment_path)
+
(self.class.constants - constants).each do |const|
Object.const_set(const, self.class.const_get(const))
end
diff --git a/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb b/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
index df622f7eee..855f9119d5 100644
--- a/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
+++ b/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
@@ -173,7 +173,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
sandbox.model_instance = model_instance
sandbox.instance_variable_set("@#{singular_name}", sandbox.model_instance)
rescue ActiveRecord::StatementInvalid => e
- logger.error "Before updating scaffolding from new DB schema, try creating a table for your model (#{class_name})"
+ logger.error "Before updating scaffolding from new DB schema, try creating a table for your model (#{class_name}) named #{class_name.tableize}."
raise SystemExit
end
sandbox.suffix = suffix