Changeset 6471
- Timestamp:
- 03/27/07 14:04:38 (2 years ago)
- Files:
-
- branches/1-2-stable/actionpack/CHANGELOG (modified) (1 diff)
- branches/1-2-stable/actionpack/lib/action_controller/assertions/dom_assertions.rb (modified) (2 diffs)
- branches/1-2-stable/actionpack/lib/action_controller/assertions/model_assertions.rb (modified) (1 diff)
- branches/1-2-stable/actionpack/lib/action_controller/assertions/response_assertions.rb (modified) (2 diffs)
- branches/1-2-stable/actionpack/lib/action_controller/assertions/routing_assertions.rb (modified) (1 diff)
- branches/1-2-stable/actionpack/lib/action_controller/base.rb (modified) (1 diff)
- branches/1-2-stable/actionpack/lib/action_controller/url_rewriter.rb (modified) (2 diffs)
- branches/1-2-stable/actionpack/lib/action_view/base.rb (modified) (12 diffs)
- branches/1-2-stable/actionpack/lib/action_view/compiled_templates.rb (modified) (2 diffs)
- branches/1-2-stable/actionpack/lib/action_view/helpers/active_record_helper.rb (modified) (7 diffs)
- branches/1-2-stable/actionpack/lib/action_view/helpers/debug_helper.rb (modified) (1 diff)
- branches/1-2-stable/actionpack/lib/action_view/helpers/deprecated_helper.rb (modified) (1 diff)
- branches/1-2-stable/activerecord/CHANGELOG (modified) (1 diff)
- branches/1-2-stable/activerecord/lib/active_record/acts/list.rb (modified) (7 diffs)
- branches/1-2-stable/activerecord/lib/active_record/acts/tree.rb (modified) (2 diffs)
- branches/1-2-stable/activerecord/lib/active_record/associations.rb (modified) (3 diffs)
- branches/1-2-stable/activerecord/lib/active_record/base.rb (modified) (1 diff)
- branches/1-2-stable/activerecord/lib/active_record/calculations.rb (modified) (1 diff)
- branches/1-2-stable/activerecord/lib/active_record/deprecated_finders.rb (modified) (3 diffs)
- branches/1-2-stable/railties/CHANGELOG (modified) (1 diff)
- branches/1-2-stable/railties/lib/initializer.rb (modified) (1 diff)
- branches/1-2-stable/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1-2-stable/actionpack/CHANGELOG
r6432 r6471 1 1 *SVN* 2 3 * Cleaned up, corrected, and mildly expanded ActionPack documentation. Closes #7190 [jeremymcanally] 4 5 * Small collection of ActionController documentation cleanups. Closes #7319 [jeremymcanally] 2 6 3 7 * Performance: patch cgi/session/pstore to require digest/md5 once rather than per #initialize. #7583 [Stefan Kaes] branches/1-2-stable/actionpack/lib/action_controller/assertions/dom_assertions.rb
r4935 r6471 2 2 module Assertions 3 3 module DomAssertions 4 # test 2 html strings to be equivalent, i.e. identical up to reordering of attributes4 # Test two HTML strings for equivalency (e.g., identical up to reordering of attributes) 5 5 def assert_dom_equal(expected, actual, message="") 6 6 clean_backtrace do … … 12 12 end 13 13 14 # negated form of +assert_dom_equivalent+14 # The negated form of +assert_dom_equivalent+. 15 15 def assert_dom_not_equal(expected, actual, message="") 16 16 clean_backtrace do branches/1-2-stable/actionpack/lib/action_controller/assertions/model_assertions.rb
r4935 r6471 2 2 module Assertions 3 3 module ModelAssertions 4 # ensures that the passed record is valid by active record standards. returns the error messages if not4 # Ensures that the passed record is valid by ActiveRecord standards and returns any error messages if it is not. 5 5 def assert_valid(record) 6 6 clean_backtrace do branches/1-2-stable/actionpack/lib/action_controller/assertions/response_assertions.rb
r5788 r6471 121 121 122 122 private 123 # Recognizes the route for a given path. 123 124 def recognized_request_for(path, request_method = nil) 124 125 path = "/#{path}" unless path.first == '/' … … 133 134 end 134 135 136 # Proxy to to_param if the object will respond to it. 135 137 def parameterize(value) 136 138 value.respond_to?(:to_param) ? value.to_param : value branches/1-2-stable/actionpack/lib/action_controller/assertions/routing_assertions.rb
r6114 r6471 83 83 84 84 private 85 # Recognizes the route for a given path. 85 86 def recognized_request_for(path, request_method = nil) 86 87 path = "/#{path}" unless path.first == '/' branches/1-2-stable/actionpack/lib/action_controller/base.rb
r6254 r6471 539 539 end 540 540 541 # Test whether the session is enabled for this request. 541 542 def session_enabled? 542 543 request.session_options && request.session_options[:disabled] != false branches/1-2-stable/actionpack/lib/action_controller/url_rewriter.rb
r5054 r6471 77 77 78 78 private 79 # Given a path and options, returns a rewritten URL string 79 80 def rewrite_url(path, options) 80 81 rewritten_url = "" … … 92 93 end 93 94 95 # Given a Hash of options, generates a route 94 96 def rewrite_path(options) 95 97 options = options.symbolize_keys branches/1-2-stable/actionpack/lib/action_view/base.rb
r5231 r6471 149 149 # This refreshes the sidebar, removes a person element and highlights the user list. 150 150 # 151 # See the ActionView::Helpers::PrototypeHelper:: JavaScriptGeneratordocumentation for more details.151 # See the ActionView::Helpers::PrototypeHelper::GeneratorMethods documentation for more details. 152 152 class Base 153 153 include ERB::Util … … 161 161 162 162 # Specify trim mode for the ERB compiler. Defaults to '-'. 163 # See ER Bdocumentation for suitable values.163 # See ERb documentation for suitable values. 164 164 @@erb_trim_mode = '-' 165 165 cattr_accessor :erb_trim_mode … … 192 192 include CompiledTemplates 193 193 194 # maps inline templates to their method names194 # Maps inline templates to their method names 195 195 @@method_names = {} 196 # map method names to their compile time196 # Map method names to their compile time 197 197 @@compile_time = {} 198 # map method names to the names passed in local assigns so far198 # Map method names to the names passed in local assigns so far 199 199 @@template_args = {} 200 # count the number of inline templates200 # Count the number of inline templates 201 201 @@inline_template_count = 0 202 # maps template paths without extension to their file extension returned by pick_template_extension.203 # if for a given path, path.ext1 and path.ext2 exist on the file system, the order of extensions204 # used by pick_template_extension determines whether ext1 or ext2 will be stored 202 # Maps template paths without extension to their file extension returned by pick_template_extension. 203 # If for a given path, path.ext1 and path.ext2 exist on the file system, the order of extensions 204 # used by pick_template_extension determines whether ext1 or ext2 will be stored. 205 205 @@cached_template_extension = {} 206 206 … … 306 306 # local assigns yet, or if the template has been updated on disk, then the template will be compiled to a method. 307 307 # 308 309 308 # Either, but not both, of template and file_path may be nil. If file_path is given, the template 310 309 # will only be read if it has to be compiled. … … 372 371 373 372 private 373 # Builds a string holding the full path of the template including extension 374 374 def full_template_path(template_path, extension) 375 375 "#{@base_path}/#{template_path}.#{extension}" 376 376 end 377 377 378 # Asserts the existence of a template. 378 379 def template_exists?(template_path, extension) 379 380 file_path = full_template_path(template_path, extension) … … 390 391 end 391 392 393 # Determines the template's file extension, such as rhtml, rxml, or rjs. 392 394 def find_template_extension_for(template_path) 393 395 if match = delegate_template_exists?(template_path) … … 406 408 end 407 409 410 # Evaluate the local assigns and pushes them to the view. 408 411 def evaluate_assigns 409 412 unless @assigns_added … … 417 420 end 418 421 422 # Assigns instance variables from the controller to the view. 419 423 def assign_variables_from_controller 420 424 @assigns.each { |key, value| instance_variable_set("@#{key}", value) } … … 428 432 end 429 433 430 # Check whethercompilation is necessary.431 # Compile if the inline template or file has not been compiled yet.432 # Or if local_assigns has a new key, which isn't supported by the compiled code yet.433 # Or if the file has changed on disk and checking file mods hasn't been disabled.434 # Method to check whether template compilation is necessary. 435 # The template will be compiled if the inline template or file has not been compiled yet, 436 # if local_assigns has a new key, which isn't supported by the compiled code yet, 437 # or if the file has changed on disk and checking file mods hasn't been disabled. 434 438 def compile_template?(template, file_name, local_assigns) 435 439 method_key = file_name || template … … 446 450 end 447 451 448 # Create source code for given template452 # Method to create the source code for a given template. 449 453 def create_template_source(extension, template, render_symbol, locals) 450 454 if template_requires_setup?(extension) … … 474 478 end 475 479 476 def template_requires_setup?(extension) 480 def template_requires_setup?(extension) #:nodoc: 477 481 templates_requiring_setup.include? extension.to_s 478 482 end 479 483 480 def templates_requiring_setup 484 def templates_requiring_setup #:nodoc: 481 485 %w(rxml rjs) 482 486 end … … 502 506 end 503 507 508 # Compile and evaluate the template's code 504 509 def compile_template(extension, template, file_name, local_assigns) 505 510 render_symbol = assign_method_name(extension, template, file_name) branches/1-2-stable/actionpack/lib/action_view/compiled_templates.rb
r4885 r6471 4 4 # CompiledTemplates modules hold methods that have been compiled. 5 5 # Templates are compiled into these methods so that they do not need to be 6 # re -read and re-parsedeach request.6 # read and parsed for each request. 7 7 # 8 8 # Each template may be compiled into one or more methods. Each method accepts a given … … 11 11 # To use a compiled template module, create a new instance and include it into the class 12 12 # in which you want the template to be rendered. 13 class CompiledTemplates < Module #:nodoc:13 class CompiledTemplates < Module 14 14 attr_reader :method_names 15 15 branches/1-2-stable/actionpack/lib/action_view/helpers/active_record_helper.rb
r5871 r6471 14 14 # In that case, it's better to use the input method and the specialized form methods in link:classes/ActionView/Helpers/FormHelper.html 15 15 module ActiveRecordHelper 16 # Returns a default input tag for the type of object returned by the method. Example17 # (title is a VARCHAR column and holds "Hello World"):16 # Returns a default input tag for the type of object returned by the method. For example, let's say you have a model 17 # that has an attribute +title+ of type VARCHAR column, and this instance holds "Hello World": 18 18 # input("post", "title") => 19 19 # <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /> … … 22 22 end 23 23 24 # Returns an entire form with input tags and everything for a specified Active Record object. Example 25 # (post is a new record that has a title using VARCHAR and a body using TEXT): 26 # form("post") => 24 # Returns an entire form with all needed input tags for a specified Active Record object. For example, let's say you 25 # 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>: 26 # form("post") 27 # That line would yield a form like the following: 27 28 # <form action='/post/create' method='post'> 28 29 # <p> … … 33 34 # <label for="post_body">Body</label><br /> 34 35 # <textarea cols="40" id="post_body" name="post[body]" rows="20"> 35 # Back to the hill and over it again!36 36 # </textarea> 37 37 # </p> … … 40 40 # 41 41 # It's possible to specialize the form builder by using a different action name and by supplying another 42 # block renderer. Example (entry is a new record that has a message attribute using VARCHAR):42 # 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>: 43 43 # 44 44 # form("entry", :action => "sign", :input_block => … … 75 75 end 76 76 77 # Returns a string containing the error message attached to the +method+ on the +object+ ,if one exists.78 # This error message is wrapped in a DIV tag, which can be specialized to include both a +prepend_text+ and+append_text+79 # to properly introduce the error and a +css_class+ to style it accordingly. Examples (post has an error message80 # "can't be empty" on the title attribute):77 # Returns a string containing the error message attached to the +method+ on the +object+ if one exists. 78 # This error message is wrapped in a <tt>DIV</tt> tag, which can be extended to include a +prepend_text+ and/or +append_text+ 79 # (to properly explain the error), and a +css_class+ to style it accordingly. As an example, let's say you have a model 80 # +post+ that has an error message on the +title+ attribute: 81 81 # 82 82 # <%= error_message_on "post", "title" %> => 83 83 # <div class="formError">can't be empty</div> 84 84 # 85 # <%= error_message_on "post", "title", "Title simply ", " (or it won't work) ", "inputError" %> =>86 # <div class="inputError">Title simply can't be empty (or it won't work) </div>85 # <%= error_message_on "post", "title", "Title simply ", " (or it won't work).", "inputError" %> => 86 # <div class="inputError">Title simply can't be empty (or it won't work).</div> 87 87 def error_message_on(object, method, prepend_text = "", append_text = "", css_class = "formError") 88 88 if (obj = instance_variable_get("@#{object}")) && (errors = obj.errors.on(method)) … … 93 93 end 94 94 95 # Returns a string with a divcontaining all of the error messages for the objects located as instance variables by the names95 # Returns a string with a <tt>DIV</tt> containing all of the error messages for the objects located as instance variables by the names 96 96 # given. If more than one object is specified, the errors for the objects are displayed in the order that the object names are 97 97 # provided. 98 98 # 99 # This divcan be tailored by the following options:99 # This <tt>DIV</tt> can be tailored by the following options: 100 100 # 101 101 # * <tt>header_tag</tt> - Used for the header of the error div (default: h2) … … 106 106 # the first object will be used. 107 107 # 108 # Specifying one object:108 # To specify the display for one object, you simply provide its name as a parameter. For example, for the +User+ model: 109 109 # 110 110 # error_messages_for 'user' 111 111 # 112 # Specifying more than one object (and using the name 'user' in the113 # header as the <tt>object_name</tt> instead of 'user_common'):112 # To specify more than one object, you simply list them; optionally, you can add an extra +object_name+ parameter, which 113 # be the name in the header. 114 114 # 115 115 # error_messages_for 'user_common', 'user', :object_name => 'user' branches/1-2-stable/actionpack/lib/action_view/helpers/debug_helper.rb
r4885 r6471 4 4 module DebugHelper 5 5 # Returns a <pre>-tag set with the +object+ dumped by YAML. Very readable way to inspect an object. 6 # my_hash = {'first' => 1, 'second' => 'two', 'third' => [1,2,3]} 7 # debug(my_hash) 8 # => <pre class='debug_dump'>--- 9 # first: 1 10 # second: two 11 # third: 12 # - 1 13 # - 2 14 # - 3 15 # </pre> 6 16 def debug(object) 7 17 begin branches/1-2-stable/actionpack/lib/action_view/helpers/deprecated_helper.rb
r5439 r6471 3 3 module PrototypeHelper 4 4 5 # Method to execute an element update using Prototype. 6 # DEPRECATION WARNING: This helper has been depercated; use RJS instead. 7 # See ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMethods for more information. 5 8 def update_element_function(element_id, options = {}, &block) 6 9 content = escape_javascript(options[:content] || '') branches/1-2-stable/activerecord/CHANGELOG
r6450 r6471 1 1 *SVN* 2 3 * Small additions and fixes for ActiveRecord documentation. Closes #7342 [jeremymcanally] 2 4 3 5 * SQLite: binary escaping works with $KCODE='u'. #7862 [tsuka] branches/1-2-stable/activerecord/lib/active_record/acts/list.rb
r4543 r6471 75 75 # the first in the list of all chapters. 76 76 module InstanceMethods 77 # Insert the item at the given position (defaults to the top position of 1). 77 78 def insert_at(position = 1) 78 79 insert_at_position(position) … … 119 120 end 120 121 122 # Removes the item from the list. 121 123 def remove_from_list 122 124 decrement_positions_on_lower_items if in_list? … … 163 165 end 164 166 167 # Test if this record is in a list 165 168 def in_list? 166 169 !send(position_column).nil? … … 179 182 def scope_condition() "1" end 180 183 184 # Returns the bottom position number in the list. 185 # bottom_position_in_list # => 2 181 186 def bottom_position_in_list(except = nil) 182 187 item = bottom_item(except) … … 184 189 end 185 190 191 # Returns the bottom item 186 192 def bottom_item(except = nil) 187 193 conditions = scope_condition … … 190 196 end 191 197 198 # Forces item to assume the bottom position in the list. 192 199 def assume_bottom_position 193 200 update_attribute(position_column, bottom_position_in_list(self).to_i + 1) 194 201 end 195 202 203 # Forces item to assume the top position in the list. 196 204 def assume_top_position 197 205 update_attribute(position_column, 1) … … 228 236 end 229 237 238 # Increments position (<tt>position_column</tt>) of all items in the list. 230 239 def increment_positions_on_all_items 231 240 acts_as_list_class.update_all( branches/1-2-stable/activerecord/lib/active_record/acts/tree.rb
r5116 r6471 71 71 end 72 72 73 # Returns the root node of the tree. 73 74 def root 74 75 node = self … … 77 78 end 78 79 80 # Returns all siblings of the current node. 81 # 82 # subchild1.siblings # => [subchild2] 79 83 def siblings 80 84 self_and_siblings - [self] 81 85 end 82 86 87 # Returns all siblings and a reference to the current node. 88 # 89 # subchild1.self_and_siblings # => [subchild1, subchild2] 83 90 def self_and_siblings 84 91 parent ? parent.children : self.class.roots branches/1-2-stable/activerecord/lib/active_record/associations.rb
r6410 r6471 735 735 end 736 736 737 # Create the callbacks to update counter cache 737 738 if options[:counter_cache] 738 739 cache_column = options[:counter_cache] == true ? … … 872 873 873 874 private 875 # Generate a join table name from two provided tables names. 876 # The order of names in join name is determined by lexical precedence. 877 # join_table_name("members", "clubs") 878 # => "clubs_members" 879 # join_table_name("members", "special_clubs") 880 # => "members_special_clubs" 874 881 def join_table_name(first_table_name, second_table_name) 875 882 if first_table_name < second_table_name … … 881 888 table_name_prefix + join_table + table_name_suffix 882 889 end 883 890 884 891 def association_accessor_methods(reflection, association_proxy_class) 885 892 define_method(reflection.name) do |*params| branches/1-2-stable/activerecord/lib/active_record/base.rb
r6417 r6471 1189 1189 # It's even possible to use all the additional parameters to find. For example, the full interface for find_all_by_amount 1190 1190 # is actually find_all_by_amount(amount, options). 1191 # 1192 # This also enables you to initialize a record if it is not found, such as find_or_initialize_by_amount(amount) 1193 # or find_or_create_by_user_and_password(user, password). 1191 1194 def method_missing(method_id, *arguments) 1192 1195 if match = /^find_(all_by|by)_([_a-zA-Z]\w*)$/.match(method_id.to_s) branches/1-2-stable/activerecord/lib/active_record/calculations.rb
r5932 r6471 243 243 end 244 244 245 # converts a given key to the value that the database adapter returns as246 # 245 # Converts a given key to the value that the database adapter returns as 246 # as a usable column name. 247 247 # users.id #=> users_id 248 248 # sum(id) #=> sum_id branches/1-2-stable/activerecord/lib/active_record/deprecated_finders.rb
r5359 r6471 2 2 class Base 3 3 class << self 4 # This method is deprecated in favor of find with the :conditions option.4 # DEPRECATION NOTICE: This method is deprecated in favor of find with the :conditions option. 5 5 # 6 6 # Works like find, but the record matching +id+ must also meet the +conditions+. … … 13 13 deprecate :find_on_conditions => "use find(ids, :conditions => conditions)" 14 14 15 # This method is deprecated in favor of find(:first, options).15 # DEPRECATION NOTICE: This method is deprecated in favor of find(:first, options). 16 16 # 17 17 # Returns the object for the first record responding to the conditions in +conditions+, … … 25 25 deprecate :find_first => "use find(:first, ...)" 26 26 27 # This method is deprecated in favor of find(:all, options).27 # DEPRECATION NOTICE: This method is deprecated in favor of find(:all, options). 28 28 # 29 29 # Returns an array of all the objects that could be instantiated from the associated branches/1-2-stable/railties/CHANGELOG
r6447 r6471 1 1 *SVN* 2 2 3 * Give generate scaffold a more descriptive database message. Closes #7316 [jeremymcanally] 4 3 5 * 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] 4 5 6 6 7 *1.2.3* (March 12th, 2007) branches/1-2-stable/railties/lib/initializer.rb
r6447 r6471 206 206 config = configuration 207 207 constants = self.class.constants 208 208 209 eval(IO.read(configuration.environment_path), binding, configuration.environment_path) 210 209 211 (self.class.constants - constants).each do |const| 210 212 Object.const_set(const, self.class.const_get(const)) branches/1-2-stable/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
r5693 r6471 174 174 sandbox.instance_variable_set("@#{singular_name}", sandbox.model_instance) 175 175 rescue ActiveRecord::StatementInvalid => e 176 logger.error "Before updating scaffolding from new DB schema, try creating a table for your model (#{class_name}) "176 logger.error "Before updating scaffolding from new DB schema, try creating a table for your model (#{class_name}) named #{class_name.tableize}." 177 177 raise SystemExit 178 178 end