From 7290fb2eaaeb4dfc187cdc0b882a94f130900533 Mon Sep 17 00:00:00 2001 From: Ryunosuke SATO Date: Tue, 5 Feb 2013 09:53:28 +0900 Subject: Fix file name in document [ci skip] This file was renamed in c8a25386d. --- guides/source/contributing_to_ruby_on_rails.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index baef620c6c..7909a00c47 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -85,7 +85,7 @@ You can also run any single test separately: $ ARCONN=sqlite3 ruby -Itest test/cases/associations/has_many_associations_test.rb ``` -You can invoke `test_jdbcmysql`, `test_jdbcsqlite3` or `test_jdbcpostgresql` also. See the file `activerecord/RUNNING_UNIT_TESTS` for information on running more targeted database tests, or the file `ci/travis.rb` for the test suite run by the continuous integration server. +You can invoke `test_jdbcmysql`, `test_jdbcsqlite3` or `test_jdbcpostgresql` also. See the file `activerecord/RUNNING_UNIT_TESTS.rdoc` for information on running more targeted database tests, or the file `ci/travis.rb` for the test suite run by the continuous integration server. ### Warnings -- cgit v1.2.3 From 045f0195e09828fad7770794ade996aa62664647 Mon Sep 17 00:00:00 2001 From: Henrik Nyh Date: Sat, 9 Feb 2013 15:47:22 +0100 Subject: Validations guide: validates_with init clarification. As discussed with @josevalim on Ruby Rogues Parley. --- guides/source/active_record_validations.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'guides/source') diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md index eaa47d4ebf..32641d04c1 100644 --- a/guides/source/active_record_validations.md +++ b/guides/source/active_record_validations.md @@ -618,6 +618,35 @@ class GoodnessValidator < ActiveModel::Validator end ``` +Note that the validator will be initialized *only once* for the whole application +life cycle, and not on each validation run, so be careful about using instance +variables inside it. + +If your validator is complex enough that you want instance variables, you can +easily use a plain old Ruby object instead: + +```ruby +class Person < ActiveRecord::Base + validate do |person| + GoodnessValidator.new(person).validate + end +end + +class GoodnessValidator + def initialize(person) + @person = person + end + + def validate + if some_complex_condition_involving_ivars_and_private_methods? + @person.errors[:base] << "This person is evil" + end + end + + # … +end +``` + ### `validates_each` This helper validates attributes against a block. It doesn't have a predefined -- cgit v1.2.3 From 07f533a2dacc9a88fdf0db14c83c184dfe58e5ab Mon Sep 17 00:00:00 2001 From: Ryunosuke SATO Date: Sun, 10 Feb 2013 03:53:27 +0900 Subject: Fix CoffeeScript example `a[data-color]` is not used in example html. --- guides/source/working_with_javascript_in_rails.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md index 03ef770352..7c4192ee26 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -111,7 +111,7 @@ paintIt = (element, backgroundColor, textColor) -> element.style.color = textColor $ -> - $("a[data-color]").click -> + $("a[data-background-color]").click -> backgroundColor = $(this).data("background-color") textColor = $(this).data("text-color") paintIt(this, backgroundColor, textColor) -- cgit v1.2.3 From 24e08450ee5d67632a8a3b00447d2e804ca06798 Mon Sep 17 00:00:00 2001 From: Ryunosuke SATO Date: Sun, 10 Feb 2013 04:11:52 +0900 Subject: Fix supported ruby version for Rails 4 --- guides/source/upgrading_ruby_on_rails.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index b4a59fe3da..ea04036663 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -18,7 +18,7 @@ Rails generally stays close to the latest released Ruby version when it's releas * Rails 3 and above requires Ruby 1.8.7 or higher. Support for all of the previous Ruby versions has been dropped officially and you should upgrade as early as possible. * Rails 3.2.x will be the last branch to support Ruby 1.8.7. -* Rails 4 will support only Ruby 1.9.3. +* Rails 4 will support Ruby 1.9.3 or higher. TIP: Ruby 1.8.7 p248 and p249 have marshaling bugs that crash Rails. Ruby Enterprise Edition has these fixed since the release of 1.8.7-2010.02. On the 1.9 front, Ruby 1.9.1 is not usable because it outright segfaults, so if you want to use 1.9.x, jump on to 1.9.2 or 1.9.3 for smooth sailing. -- cgit v1.2.3 From 6530d42dbb42e87f8c8467169f143b882b2cf7f4 Mon Sep 17 00:00:00 2001 From: Americo Savinon Date: Tue, 12 Feb 2013 14:56:19 -0500 Subject: Detail Ruby 1.8 ships with TestUnit and Ruby 1.9 with MiniTest --- guides/source/testing.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/testing.md b/guides/source/testing.md index 39a44794a7..d660d8932f 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -774,10 +774,13 @@ You don't need to set up and run your tests by hand on a test-by-test basis. Rai Brief Note About `Test::Unit` ----------------------------- -Ruby ships with a boat load of libraries. One little gem of a library is `Test::Unit`, a framework for unit testing in Ruby. All the basic assertions discussed above are actually defined in `Test::Unit::Assertions`. The class `ActiveSupport::TestCase` which we have been using in our unit and functional tests extends `Test::Unit::TestCase`, allowing +Ruby ships with a boat load of libraries. In Ruby 1.8 one little gem of a library is `Test::Unit`, a framework for unit testing in Ruby. All the basic assertions discussed above are actually defined in `Test::Unit::Assertions`. The class `ActiveSupport::TestCase` which we have been using in our unit and functional tests extends `Test::Unit::TestCase`, allowing us to use all of the basic assertions in our tests. +Ruby 1.9 introduced MiniTest, an updated version of Test::Unit which provides a backwards compatible API for Test::Unit. You could also used MiniTest in Ruby 1.8 by installing the `minitest` gem. + NOTE: For more information on `Test::Unit`, refer to [test/unit Documentation](http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/) +For more information on `MiniTest`, refer to [Minitest](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/minitest/unit/rdoc/) Setup and Teardown ------------------ -- cgit v1.2.3 From 0f0803fda5df60319d8646bb4f3e71f2e596316a Mon Sep 17 00:00:00 2001 From: Kuba Brecka Date: Wed, 13 Feb 2013 20:57:06 +0100 Subject: incorrect content of models/comment.rb after 'rails generate' --- guides/source/getting_started.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'guides/source') diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index c394f30c38..f1c390570c 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -1240,6 +1240,7 @@ First, take a look at `app/models/comment.rb`: ```ruby class Comment < ActiveRecord::Base belongs_to :post + attr_accessible :body, :commenter end ``` @@ -1302,6 +1303,7 @@ makes each comment belong to a Post: ```ruby class Comment < ActiveRecord::Base belongs_to :post + attr_accessible :body, :commenter end ``` -- cgit v1.2.3 From 3a388da87dd5294f2a2718017a3d6ecc70cfdb17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 13 Feb 2013 18:00:20 -0200 Subject: Revert "incorrect content of models/comment.rb after 'rails generate'" This reverts commit 0f0803fda5df60319d8646bb4f3e71f2e596316a. Reason: The content was correct since attr_accessible was removed from rails master. --- guides/source/getting_started.md | 2 -- 1 file changed, 2 deletions(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index f1c390570c..c394f30c38 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -1240,7 +1240,6 @@ First, take a look at `app/models/comment.rb`: ```ruby class Comment < ActiveRecord::Base belongs_to :post - attr_accessible :body, :commenter end ``` @@ -1303,7 +1302,6 @@ makes each comment belong to a Post: ```ruby class Comment < ActiveRecord::Base belongs_to :post - attr_accessible :body, :commenter end ``` -- cgit v1.2.3 From 2008fe606b6096e4b8ad9c03e03b0d11b94605cd Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Fri, 15 Feb 2013 22:01:11 +0530 Subject: copy edits [ci skip] --- guides/source/testing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides/source') diff --git a/guides/source/testing.md b/guides/source/testing.md index d660d8932f..540197e6e7 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -774,10 +774,10 @@ You don't need to set up and run your tests by hand on a test-by-test basis. Rai Brief Note About `Test::Unit` ----------------------------- -Ruby ships with a boat load of libraries. In Ruby 1.8 one little gem of a library is `Test::Unit`, a framework for unit testing in Ruby. All the basic assertions discussed above are actually defined in `Test::Unit::Assertions`. The class `ActiveSupport::TestCase` which we have been using in our unit and functional tests extends `Test::Unit::TestCase`, allowing +Ruby ships with a boat load of libraries. Ruby 1.8 provides `Test::Unit`, a framework for unit testing in Ruby. All the basic assertions discussed above are actually defined in `Test::Unit::Assertions`. The class `ActiveSupport::TestCase` which we have been using in our unit and functional tests extends `Test::Unit::TestCase`, allowing us to use all of the basic assertions in our tests. -Ruby 1.9 introduced MiniTest, an updated version of Test::Unit which provides a backwards compatible API for Test::Unit. You could also used MiniTest in Ruby 1.8 by installing the `minitest` gem. +Ruby 1.9 introduced `MiniTest`, an updated version of `Test::Unit` which provides a backwards compatible API for `Test::Unit`. You could also use `MiniTest` in Ruby 1.8 by installing the `minitest` gem. NOTE: For more information on `Test::Unit`, refer to [test/unit Documentation](http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/) For more information on `MiniTest`, refer to [Minitest](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/minitest/unit/rdoc/) -- cgit v1.2.3