diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-03-05 22:58:48 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-03-05 22:58:48 +0000 |
commit | 28ed10d3f27e27ed105dd8fd60d6151a6b372375 (patch) | |
tree | ca2cfb5696cbc9de3d636212374eaeafafa23c39 /railties | |
parent | b7f1b3641afe0ff4f3cd344815c6f7bb58821e9e (diff) | |
parent | 74818a35432b40fef16fe74f248ea75d35405324 (diff) | |
download | rails-28ed10d3f27e27ed105dd8fd60d6151a6b372375.tar.gz rails-28ed10d3f27e27ed105dd8fd60d6151a6b372375.tar.bz2 rails-28ed10d3f27e27ed105dd8fd60d6151a6b372375.zip |
Merge branch 'master' into nested_has_many_through
Conflicts:
activerecord/CHANGELOG
Diffstat (limited to 'railties')
-rw-r--r-- | railties/README.rdoc | 3 | ||||
-rw-r--r-- | railties/guides/source/active_record_validations_callbacks.textile | 15 | ||||
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 4 | ||||
-rw-r--r-- | railties/guides/source/contributing_to_ruby_on_rails.textile | 23 | ||||
-rw-r--r-- | railties/guides/source/generators.textile | 2 | ||||
-rw-r--r-- | railties/guides/source/layout.html.erb | 3 | ||||
-rw-r--r-- | railties/guides/source/routing.textile | 2 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 7 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/resource_helpers.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/railtie/configuration.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/actions_test.rb | 25 |
13 files changed, 78 insertions, 18 deletions
diff --git a/railties/README.rdoc b/railties/README.rdoc index 789d5255b7..0457227473 100644 --- a/railties/README.rdoc +++ b/railties/README.rdoc @@ -4,7 +4,7 @@ Railties is responsible to glue all frameworks together. Overall, it: * handles all the bootstrapping process for a Rails application; -* manager rails command line interface; +* manages rails command line interface; * provides Rails generators core; @@ -23,3 +23,4 @@ Documentation can be found at == License Railties is released under the MIT license. + diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile index 5dc6ef3774..58a184a48e 100644 --- a/railties/guides/source/active_record_validations_callbacks.textile +++ b/railties/guides/source/active_record_validations_callbacks.textile @@ -738,7 +738,20 @@ person.errors.size # => 0 h3. Displaying Validation Errors in the View -Rails provides built-in helpers to display the error messages of your models in your view templates. +Rails maintains an official plugin that provides helpers to display the error messages of your models in your view templates. You can install it as a plugin or as a Gem. + +h4. Installing as a plugin +<shell> +$ rails plugin install git://github.com/rails/dynamic_form.git +</shell> + +h4 Installing as a Gem +Add this line on your Gemfile: +<ruby> +gem "dynamic_form" +</ruby> + +Now you will have access to these two methods in your view templates: h4. +error_messages+ and +error_messages_for+ diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index e0b1bf6e83..1df36137b4 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1045,6 +1045,8 @@ NOTE: Defined in +active_support/core_ext/class/attribute_accessors.rb+. h4. Class Inheritable Attributes +WARNING: Class Inheritable Attributes are deprecated. It's recommended that you use +Class#class_attribute+ instead. + Class variables are shared down the inheritance tree. Class instance variables are not shared, but they are not inherited either. The macros +class_inheritable_reader+, +class_inheritable_writer+, and +class_inheritable_accessor+ provide accessors for class-level data which is inherited but not shared with children: <ruby> @@ -2009,7 +2011,7 @@ That syntactic sugar is used a lot in Rails to avoid positional arguments where If a method expects a variable number of arguments and uses <tt>*</tt> in its declaration, however, such an options hash ends up being an item of the array of arguments, where it loses its role. -In those cases, you may give an options hash a distinguished treatment with +extract_options!+. That method checks the type of the last item of an array. If it is a hash it pops it and returns it, otherwise returns an empty hash. +In those cases, you may give an options hash a distinguished treatment with +extract_options!+. This method checks the type of the last item of an array. If it is a hash it pops it and returns it, otherwise it returns an empty hash. Let's see for example the definition of the +caches_action+ controller macro: diff --git a/railties/guides/source/contributing_to_ruby_on_rails.textile b/railties/guides/source/contributing_to_ruby_on_rails.textile index 1977f8d0ce..3454b8b7a3 100644 --- a/railties/guides/source/contributing_to_ruby_on_rails.textile +++ b/railties/guides/source/contributing_to_ruby_on_rails.textile @@ -101,6 +101,14 @@ $ cd actionpack $ rake test </shell> +If you want to run tests from the specific directory use the +TEST_DIR+ environment variable. For example, this will run tests inside +railties/test/generators+ directory only: + +<shell> +$ cd railties +$ TEST_DIR=generators rake test +</shell> + + h4. Warnings The test suite runs with warnings enabled. Ideally Ruby on Rails should issue no warning, but there may be a few, and also some from third-party libraries. Please ignore (or fix!) them if any, and submit patches that do not issue new warnings. @@ -341,7 +349,20 @@ $ git commit -a $ git format-patch master --stdout > my_new_patch.diff </shell> -Sanity check the results of this operation: open the diff file in your text editor of choice and make sure that no unintended changes crept in. +Open the diff file in your text editor of choice to sanity check the results, and make sure that no unintended changes crept in. + +You can also perform an extra check by applying the patch to a different dedicated branch: + +<shell> +$ git checkout -b testing_branch +$ git apply --check my_new_patch.diff +</shell> + +Please make sure the patch does not introduce whitespace errors: + +<shell> +$ git apply --whitespace=error-all mynew_patch.diff +</shell> h4. Create a Lighthouse Ticket diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile index 41a96b487d..fc7b1216d5 100644 --- a/railties/guides/source/generators.textile +++ b/railties/guides/source/generators.textile @@ -345,7 +345,7 @@ $ rails generate scaffold Comment body:text invoke shoulda create test/unit/comment_test.rb create test/fixtures/comments.yml - route map.resources :comments + route resources :comments invoke scaffold_controller create app/controllers/comments_controller.rb invoke erb diff --git a/railties/guides/source/layout.html.erb b/railties/guides/source/layout.html.erb index e924f2f6c0..f2681c6461 100644 --- a/railties/guides/source/layout.html.erb +++ b/railties/guides/source/layout.html.erb @@ -127,9 +127,6 @@ <%= link_to 'Ruby on Rails Guides Guidelines', 'ruby_on_rails_guides_guidelines.html' %> for style and conventions. </p> - <p> - Issues may also be reported in <%= link_to 'Github', 'https://github.com/lifo/docrails/issues' %>. - </p> <p>And last but not least, any kind of discussion regarding Ruby on Rails documentation is very welcome in the <%= link_to 'rubyonrails-docs mailing list', 'http://groups.google.com/group/rubyonrails-docs' %>. </p> diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile index d214031b31..c447fd911a 100644 --- a/railties/guides/source/routing.textile +++ b/railties/guides/source/routing.textile @@ -391,7 +391,7 @@ NOTE: You can't use +namespace+ or +:module+ with a +:controller+ path segment. match ':controller(/:action(/:id))', :controller => /admin\/[^\/]+/ </ruby> -TIP: By default dynamic segments don't accept dots - this is because the dot is used as a separator for formatted routes. If you need to use a dot within a dynamic segment add a constraint which overrides this - for example +:id => /[^\/]+/+ allows anything except a slash. +TIP: By default dynamic segments don't accept dots - this is because the dot is used as a separator for formatted routes. If you need to use a dot within a dynamic segment add a constraint which overrides this - for example +:id => /[^\/]<plus>/+ allows anything except a slash. h4. Static Segments diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 7c26234750..50bba22a3a 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -252,12 +252,12 @@ module Rails # end # # The routes above will automatically point to <tt>MyEngine::ApplicationContoller</tt>. Furthermore, you don't - # need to use longer url helpers like <tt>my_engine_articles_path</tt>. Instead, you shuold simply use + # need to use longer url helpers like <tt>my_engine_articles_path</tt>. Instead, you should simply use # <tt>articles_path</tt> as you would do with your application. # # To make that behaviour consistent with other parts of the framework, an isolated engine also has influence on # <tt>ActiveModel::Naming</tt>. When you use a namespaced model, like <tt>MyEngine::Article</tt>, it will normally - # use the prefix "my_engine". In an isolated engine, the prefix will be ommited in url helpers and + # use the prefix "my_engine". In an isolated engine, the prefix will be omitted in url helpers and # form fields for convenience. # # polymorphic_url(MyEngine::Article.new) #=> "articles_path" @@ -266,7 +266,7 @@ module Rails # text_field :title #=> <input type="text" name="article[title]" id="article_title" /> # end # - # Additionaly isolated engine will set its name according to namespace, so + # Additionally isolated engine will set its name according to namespace, so # MyEngine::Engine.engine_name #=> "my_engine". It will also set MyEngine.table_name_prefix # to "my_engine_", changing MyEngine::Article model to use my_engine_article table. # diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index d7a86a5c40..c323df3e95 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -264,17 +264,18 @@ module Rails # readme "README" # def readme(path) - say File.read(find_in_source_paths(path)) + log File.read(find_in_source_paths(path)) end protected # Define log for backwards compatibility. If just one argument is sent, - # invoke say, otherwise invoke say_status. + # invoke say, otherwise invoke say_status. Differently from say and + # similarly to say_status, this method respects the quiet? option given. # def log(*args) if args.size == 1 - say args.first.to_s + say args.first.to_s unless options.quiet? else args << (self.behavior == :invoke ? :green : :red) say_status *args diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb b/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb index 791b901593..dcd3b276e3 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb +++ b/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb @@ -1,4 +1,4 @@ -# Configure Rails Envinronment +# Configure Rails Environment ENV["RAILS_ENV"] = "test" require File.expand_path("../dummy/config/environment.rb", __FILE__) diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb index d6ccfc496a..de01c858dd 100644 --- a/railties/lib/rails/generators/resource_helpers.rb +++ b/railties/lib/rails/generators/resource_helpers.rb @@ -53,7 +53,7 @@ module Rails @controller_i18n_scope ||= controller_file_path.gsub('/', '.') end - # Loads the ORM::Generators::ActiveModel class. This class is responsable + # Loads the ORM::Generators::ActiveModel class. This class is responsible # to tell scaffold entities how to generate an specific method for the # ORM. Check Rails::Generators::ActiveModel for more information. def orm_class diff --git a/railties/lib/rails/railtie/configuration.rb b/railties/lib/rails/railtie/configuration.rb index afeceafb67..e4368866a1 100644 --- a/railties/lib/rails/railtie/configuration.rb +++ b/railties/lib/rails/railtie/configuration.rb @@ -18,7 +18,7 @@ module Rails # This allows you to modify application's generators from Railties. # - # Values set on app_generators will become defaults for applicaiton, unless + # Values set on app_generators will become defaults for application, unless # application overwrites them. def app_generators @@app_generators ||= Rails::Configuration::Generators.new diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index 4b29afdc8f..68d4c17623 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -191,6 +191,31 @@ class ActionsTest < Rails::Generators::TestCase assert_match(/Welcome to Rails/, action(:readme, "README")) end + def test_readme_with_quiet + generator(default_arguments, :quiet => true) + run_generator + Rails::Generators::AppGenerator.expects(:source_root).times(2).returns(destination_root) + assert_no_match(/Welcome to Rails/, action(:readme, "README")) + end + + def test_log + assert_equal("YES\n", action(:log, "YES")) + end + + def test_log_with_status + assert_equal(" yes YES\n", action(:log, :yes, "YES")) + end + + def test_log_with_quiet + generator(default_arguments, :quiet => true) + assert_equal("", action(:log, "YES")) + end + + def test_log_with_status_with_quiet + generator(default_arguments, :quiet => true) + assert_equal("", action(:log, :yes, "YES")) + end + protected def action(*args, &block) |