Changeset 6470
- Timestamp:
- 03/27/07 14:04:06 (2 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/assertions/dom_assertions.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_controller/assertions/model_assertions.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/assertions/response_assertions.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_controller/assertions/routing_assertions.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/mime_types.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/url_rewriter.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_view/base.rb (modified) (13 diffs)
- trunk/actionpack/lib/action_view/compiled_templates.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_view/helpers/active_record_helper.rb (modified) (7 diffs)
- trunk/actionpack/lib/action_view/helpers/debug_helper.rb (modified) (1 diff)
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/acts/list.rb (modified) (7 diffs)
- trunk/activerecord/lib/active_record/acts/tree.rb (modified) (2 diffs)
- trunk/activerecord/lib/active_record/associations.rb (modified) (3 diffs)
- trunk/activerecord/lib/active_record/base.rb (modified) (1 diff)
- trunk/activerecord/lib/active_record/calculations.rb (modified) (1 diff)
- trunk/activerecord/lib/active_record/deprecated_finders.rb (modified) (3 diffs)
- trunk/railties/CHANGELOG (modified) (1 diff)
- trunk/railties/lib/initializer.rb (modified) (1 diff)
- trunk/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r6465 r6470 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 * Make sure the route expiry hash is constructed by comparing the to_param-ized values of each hash. [Jamis Buck] trunk/actionpack/lib/action_controller/assertions/dom_assertions.rb
r4935 r6470 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 trunk/actionpack/lib/action_controller/assertions/model_assertions.rb
r4935 r6470 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 trunk/actionpack/lib/action_controller/assertions/response_assertions.rb
r6057 r6470 120 120 121 121 private 122 # Recognizes the route for a given path. 122 123 def recognized_request_for(path, request_method = nil) 123 124 path = "/#{path}" unless path.first == '/' … … 132 133 end 133 134 135 # Proxy to to_param if the object will respond to it. 134 136 def parameterize(value) 135 137 value.respond_to?(:to_param) ? value.to_param : value trunk/actionpack/lib/action_controller/assertions/routing_assertions.rb
r6113 r6470 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 == '/' trunk/actionpack/lib/action_controller/mime_types.rb
r6159 r6470 1 # Build list of Mime types for HTTP responses 2 # http://www.iana.org/assignments/media-types/ 3 1 4 Mime::Type.register "*/*", :all 2 5 Mime::Type.register "text/plain", :text, [], %w(txt) trunk/actionpack/lib/action_controller/url_rewriter.rb
r6314 r6470 76 76 77 77 private 78 # Given a path and options, returns a rewritten URL string 78 79 def rewrite_url(options) 79 80 rewritten_url = "" … … 95 96 end 96 97 98 # Given a Hash of options, generates a route 97 99 def rewrite_path(options) 98 100 options = options.symbolize_keys trunk/actionpack/lib/action_view/base.rb
r6399 r6470 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 … … 195 195 include CompiledTemplates 196 196 197 # maps inline templates to their method names197 # Maps inline templates to their method names 198 198 @@method_names = {} 199 # map method names to their compile time199 # Map method names to their compile time 200 200 @@compile_time = {} 201 # map method names to the names passed in local assigns so far201 # Map method names to the names passed in local assigns so far 202 202 @@template_args = {} 203 # count the number of inline templates203 # Count the number of inline templates 204 204 @@inline_template_count = 0 205 # maps template paths without extension to their file extension returned by pick_template_extension.206 # if for a given path, path.ext1 and path.ext2 exist on the file system, the order of extensions207 # used by pick_template_extension determines whether ext1 or ext2 will be stored 205 # Maps template paths without extension to their file extension returned by pick_template_extension. 206 # If for a given path, path.ext1 and path.ext2 exist on the file system, the order of extensions 207 # used by pick_template_extension determines whether ext1 or ext2 will be stored. 208 208 @@cached_template_extension = {} 209 209 … … 308 308 # local assigns yet, or if the template has been updated on disk, then the template will be compiled to a method. 309 309 # 310 311 310 # Either, but not both, of template and file_path may be nil. If file_path is given, the template 312 311 # will only be read if it has to be compiled. … … 385 384 end 386 385 386 # Asserts the existence of a template. 387 387 def template_exists?(template_path, extension) 388 388 file_path = full_template_path(template_path, extension) … … 403 403 @view_paths.find { |p| File.file?(File.join(p, template_file_name)) } 404 404 end 405 405 406 # Determines the template's file extension, such as rhtml, rxml, or rjs. 406 407 def find_template_extension_for(template_path) 407 408 if match = delegate_template_exists?(template_path) … … 420 421 end 421 422 423 # Evaluate the local assigns and pushes them to the view. 422 424 def evaluate_assigns 423 425 unless @assigns_added … … 431 433 end 432 434 435 # Assigns instance variables from the controller to the view. 433 436 def assign_variables_from_controller 434 437 @assigns.each { |key, value| instance_variable_set("@#{key}", value) } … … 442 445 end 443 446 444 # Check whethercompilation is necessary.445 # Compile if the inline template or file has not been compiled yet.446 # Or if local_assigns has a new key, which isn't supported by the compiled code yet.447 # Or if the file has changed on disk and checking file mods hasn't been disabled.447 # Method to check whether template compilation is necessary. 448 # The template will be compiled if the inline template or file has not been compiled yet, 449 # if local_assigns has a new key, which isn't supported by the compiled code yet, 450 # or if the file has changed on disk and checking file mods hasn't been disabled. 448 451 def compile_template?(template, file_name, local_assigns) 449 452 method_key = file_name || template … … 459 462 end 460 463 461 # handles checking if template changed since last compile,isolated so that templates462 # not stored on the file system can hook and extend appropriately 464 # Method to handle checking a whether a template has changed since last compile; isolated so that templates 465 # not stored on the file system can hook and extend appropriately. 463 466 def template_changed_since?(file_name, compile_time) 464 467 compile_time < File.mtime(file_name) || … … 466 469 end 467 470 468 # Create source code for given template471 # Method to create the source code for a given template. 469 472 def create_template_source(extension, template, render_symbol, locals) 470 473 if template_requires_setup?(extension) … … 494 497 end 495 498 496 def template_requires_setup?(extension) 499 def template_requires_setup?(extension) #:nodoc: 497 500 templates_requiring_setup.include? extension.to_s 498 501 end 499 502 500 def templates_requiring_setup 503 def templates_requiring_setup #:nodoc: 501 504 %w(builder rxml rjs) 502 505 end … … 522 525 end 523 526 527 # Compile and evaluate the template's code 524 528 def compile_template(extension, template, file_name, local_assigns) 525 529 render_symbol = assign_method_name(extension, template, file_name) trunk/actionpack/lib/action_view/compiled_templates.rb
r4885 r6470 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 trunk/actionpack/lib/action_view/helpers/active_record_helper.rb
r6057 r6470 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' trunk/actionpack/lib/action_view/helpers/debug_helper.rb
r4885 r6470 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 trunk/activerecord/CHANGELOG
r6469 r6470 1 1 *SVN* 2 3 * Small additions and fixes for ActiveRecord documentation. Closes #7342 [jeremymcanally] 2 4 3 5 * Add helpful debugging info to the ActiveRecord::StatementInvalid exception in ActiveRecord::ConnectionAdapters::SqliteAdapter#table_structure. Closes #7925. [court3nay] trunk/activerecord/lib/active_record/acts/list.rb
r4543 r6470 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( trunk/activerecord/lib/active_record/acts/tree.rb
r5116 r6470 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 trunk/activerecord/lib/active_record/associations.rb
r6442 r6470 799 799 end 800 800 801 # Create the callbacks to update counter cache 801 802 if options[:counter_cache] 802 803 cache_column = options[:counter_cache] == true ? … … 936 937 937 938 private 939 # Generate a join table name from two provided tables names. 940 # The order of names in join name is determined by lexical precedence. 941 # join_table_name("members", "clubs") 942 # => "clubs_members" 943 # join_table_name("members", "special_clubs") 944 # => "members_special_clubs" 938 945 def join_table_name(first_table_name, second_table_name) 939 946 if first_table_name < second_table_name … … 945 952 table_name_prefix + join_table + table_name_suffix 946 953 end 947 954 948 955 def association_accessor_methods(reflection, association_proxy_class) 949 956 define_method(reflection.name) do |*params| trunk/activerecord/lib/active_record/base.rb
r6440 r6470 1230 1230 # It's even possible to use all the additional parameters to find. For example, the full interface for find_all_by_amount 1231 1231 # is actually find_all_by_amount(amount, options). 1232 # 1233 # This also enables you to initialize a record if it is not found, such as find_or_initialize_by_amount(amount) 1234 # or find_or_create_by_user_and_password(user, password). 1232 1235 def method_missing(method_id, *arguments) 1233 1236 if match = /^find_(all_by|by)_([_a-zA-Z]\w*)$/.match(method_id.to_s) trunk/activerecord/lib/active_record/calculations.rb
r5426 r6470 247 247 end 248 248 249 # converts a given key to the value that the database adapter returns as250 # 249 # Converts a given key to the value that the database adapter returns as 250 # as a usable column name. 251 251 # users.id #=> users_id 252 252 # sum(id) #=> sum_id trunk/activerecord/lib/active_record/deprecated_finders.rb
r5359 r6470 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 trunk/railties/CHANGELOG
r6445 r6470 1 1 *SVN* 2 3 * Give generate scaffold a more descriptive database message. Closes #7316 [jeremymcanally] 2 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] trunk/railties/lib/initializer.rb
r6445 r6470 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)) trunk/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
r6180 r6470 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