aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-03-20 02:15:29 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-03-20 02:15:29 +0000
commit54213dadfde64e163d841056238b3c463aaa4212 (patch)
tree39fe86a2c5e79a1a67008fcbac34acf13caa4c15
parente87d3e333588b8455c2b6d81219adb860c2f4baa (diff)
downloadrails-54213dadfde64e163d841056238b3c463aaa4212.tar.gz
rails-54213dadfde64e163d841056238b3c463aaa4212.tar.bz2
rails-54213dadfde64e163d841056238b3c463aaa4212.zip
Docfixes (closes #11356, #11172, #10523)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9064 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb15
-rw-r--r--actionpack/test/template/form_options_helper_test.rb13
-rwxr-xr-xactiverecord/lib/active_record/associations.rb3
-rw-r--r--railties/README2
4 files changed, 32 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index 67be4d81f0..5b026245da 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -53,6 +53,21 @@ module ActionView
# <option value="2">Sam</option>
# <option value="3">Tobias</option>
# </select>
+ #
+ # Like the other form helpers, +select+ can accept an <tt>:index</tt> option to manually set the ID used in the resulting output. Unlike other helpers, +select+ expects this
+ # option to be in the +html_options+ parameter.
+ #
+ # Example:
+ #
+ # select("album[]", "genre", %w[rap rock country], {}, { :index => nil })
+ #
+ # becomes:
+ #
+ # <select name="album[][genre]" id="album__genre">
+ # <option value="rap">rap</option>
+ # <option value="rock">rock</option>
+ # <option value="country">country</option>
+ # </select>
module FormOptionsHelper
include ERB::Util
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb
index 8ee601f478..f3ecc18233 100644
--- a/actionpack/test/template/form_options_helper_test.rb
+++ b/actionpack/test/template/form_options_helper_test.rb
@@ -31,6 +31,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
Continent = Struct.new('Continent', :continent_name, :countries)
Country = Struct.new('Country', :country_id, :country_name)
Firm = Struct.new('Firm', :time_zone)
+ Album = Struct.new('Album', :id, :title, :genre)
end
def test_collection_options
@@ -305,6 +306,18 @@ class FormOptionsHelperTest < Test::Unit::TestCase
select("post", "category", %w( abe <mus> hest ), :selected => 'abe')
)
end
+
+ def test_select_with_index_option
+ @album = Album.new
+ @album.id = 1
+
+ expected = "<select id=\"album__genre\" name=\"album[][genre]\"><option value=\"rap\">rap</option>\n<option value=\"rock\">rock</option>\n<option value=\"country\">country</option></select>"
+
+ assert_dom_equal(
+ expected,
+ select("album[]", "genre", %w[rap rock country], {}, { :index => nil })
+ )
+ end
def test_select_with_selected_nil
@post = Post.new
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index d8332249fb..d7d5d9b312 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -809,6 +809,8 @@ module ActiveRecord
# destroyed. This requires that a column named <tt>#{table_name}_count</tt> (such as +comments_count+ for a belonging +Comment+ class)
# is used on the associate class (such as a +Post+ class). You can also specify a custom counter cache column by providing
# a column name instead of a +true+/+false+ value to this option (e.g., <tt>:counter_cache => :my_custom_counter</tt>.)
+ # When creating a counter cache column, the database statement or migration must specify a default value of <tt>0</tt>, failing to do
+ # this results in a counter with NULL value, which will never increment.
# Note: Specifying a counter_cache will add it to that model's list of readonly attributes using #attr_readonly.
# * <tt>:include</tt> - specify second-order associations that should be eager loaded when this object is loaded.
# Not allowed if the association is polymorphic.
@@ -824,6 +826,7 @@ module ActiveRecord
# :conditions => 'discounts > #{payments_count}'
# belongs_to :attachable, :polymorphic => true
# belongs_to :project, :readonly => true
+ # belongs_to :post, :counter_cache => true
def belongs_to(association_id, options = {})
reflection = create_belongs_to_reflection(association_id, options)
diff --git a/railties/README b/railties/README
index a1db73c4b7..fec796013d 100644
--- a/railties/README
+++ b/railties/README
@@ -31,7 +31,7 @@ link:files/vendor/rails/actionpack/README.html.
and your application name. Ex: rails myapp
(If you've downloaded Rails in a complete tgz or zip, this step is already done)
2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
-3. Go to http://localhost:3000/ and get "Welcome aboard: You’re riding the Rails!"
+3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
4. Follow the guidelines to start developing your application