diff options
-rw-r--r-- | actionview/lib/action_view/helpers/url_helper.rb | 32 | ||||
-rw-r--r-- | activejob/lib/active_job/queue_adapters.rb | 26 | ||||
-rw-r--r-- | activerecord/lib/active_record/validations/presence.rb | 4 | ||||
-rw-r--r-- | guides/rails_guides/levenshtein.rb | 7 | ||||
-rw-r--r-- | guides/source/action_view_overview.md | 30 | ||||
-rw-r--r-- | guides/source/association_basics.md | 7 | ||||
-rw-r--r-- | guides/source/initialization.md | 4 | ||||
-rw-r--r-- | railties/CHANGELOG.md | 4 | ||||
-rwxr-xr-x | railties/exe/rails (renamed from railties/bin/rails) | 0 | ||||
-rw-r--r-- | railties/lib/rails/generators.rb | 7 | ||||
-rw-r--r-- | railties/railties.gemspec | 4 | ||||
-rw-r--r-- | railties/test/isolation/abstract_unit.rb | 2 | ||||
-rw-r--r-- | railties/test/railties/generators_test.rb | 2 |
13 files changed, 55 insertions, 74 deletions
diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb index 8843a89362..afb1265ad9 100644 --- a/actionview/lib/action_view/helpers/url_helper.rb +++ b/actionview/lib/action_view/helpers/url_helper.rb @@ -476,57 +476,45 @@ module ActionView # True if the current request URI was generated by the given +options+. # # ==== Examples - # Let's say we're in the <tt>http://www.example.com/shop/checkout?order=desc</tt> action. + # Let's say we're in the <tt>http://www.example.com/shop/checkout?order=desc&page=1</tt> action. # # current_page?(action: 'process') # # => false # - # current_page?(controller: 'shop', action: 'checkout') - # # => true - # - # current_page?(controller: 'shop', action: 'checkout', order: 'asc') - # # => false - # # current_page?(action: 'checkout') # # => true # # current_page?(controller: 'library', action: 'checkout') # # => false # - # current_page?('http://www.example.com/shop/checkout') - # # => true - # - # current_page?('/shop/checkout') + # current_page?(controller: 'shop', action: 'checkout') # # => true # - # Let's say we're in the <tt>http://www.example.com/shop/checkout?order=desc&page=1</tt> action. - # - # current_page?(action: 'process') + # current_page?(controller: 'shop', action: 'checkout', order: 'asc') # # => false # - # current_page?(controller: 'shop', action: 'checkout') - # # => true - # # current_page?(controller: 'shop', action: 'checkout', order: 'desc', page: '1') # # => true # # current_page?(controller: 'shop', action: 'checkout', order: 'desc', page: '2') # # => false # - # current_page?(controller: 'shop', action: 'checkout', order: 'desc') - # # => false + # current_page?('http://www.example.com/shop/checkout') + # # => true # - # current_page?(action: 'checkout') + # current_page?('/shop/checkout') # # => true # - # current_page?(controller: 'library', action: 'checkout') - # # => false + # current_page?('http://www.example.com/shop/checkout?order=desc&page=1') + # # => true # # Let's say we're in the <tt>http://www.example.com/products</tt> action with method POST in case of invalid product. # # current_page?(controller: 'product', action: 'index') # # => false # + # We can also pass in the symbol arguments instead of strings. + # def current_page?(options) unless request raise "You cannot use helpers that need to determine the current " \ diff --git a/activejob/lib/active_job/queue_adapters.rb b/activejob/lib/active_job/queue_adapters.rb index 46caa5c6a5..8aa85979f6 100644 --- a/activejob/lib/active_job/queue_adapters.rb +++ b/activejob/lib/active_job/queue_adapters.rb @@ -37,7 +37,8 @@ module ActiveJob # # ==== Queues # - # Yes: Jobs may set which queue they are run in with queue_as or by using the set method. + # Yes: Jobs may set which queue they are run in with queue_as or by using the set + # method. # # ==== Delayed # @@ -56,13 +57,17 @@ module ActiveJob # # ==== Priorities # - # The order in which jobs are processed can be configured differently depending on the adapter. + # The order in which jobs are processed can be configured differently depending + # on the adapter. # - # Job: Any class inheriting from the adapter may set the priority on the job object relative to other jobs. + # Job: Any class inheriting from the adapter may set the priority on the job + # object relative to other jobs. # - # Queue: The adapter can set the priority for job queues, when setting a queue with Active Job this will be respected. + # Queue: The adapter can set the priority for job queues, when setting a queue + # with Active Job this will be respected. # - # Yes: Allows the priority to be set on the job object, at the queue level or as default configuration option. + # Yes: Allows the priority to be set on the job object, at the queue level or + # as default configuration option. # # No: Does not allow the priority of jobs to be configured. # @@ -78,18 +83,21 @@ module ActiveJob # # Global: The adapter is configured that all jobs have a maximum run time. # - # N/A: This adapter does not run in a separate process, and therefore timeout is unsupported. + # N/A: This adapter does not run in a separate process, and therefore timeout + # is unsupported. # # ==== Retries # # Job: The number of retries can be set per instance of the job class. # - # Yes: The Number of retries can be configured globally, for each instance or on the queue. - # This adapter may also present failed instances of the job class that can be restarted. + # Yes: The Number of retries can be configured globally, for each instance or + # on the queue. This adapter may also present failed instances of the job class + # that can be restarted. # # Global: The adapter has a global number of retries. # - # N/A: The adapter does not run in a separate process, and therefore doesn't support retries. + # N/A: The adapter does not run in a separate process, and therefore doesn't + # support retries. module QueueAdapters extend ActiveSupport::Autoload diff --git a/activerecord/lib/active_record/validations/presence.rb b/activerecord/lib/active_record/validations/presence.rb index 75d5bd5a35..a9b791397b 100644 --- a/activerecord/lib/active_record/validations/presence.rb +++ b/activerecord/lib/active_record/validations/presence.rb @@ -43,6 +43,10 @@ module ActiveRecord # deletes the associated object, thus putting the parent object into an invalid # state. # + # NOTE: This validation will not fail while using it with an association + # if the latter was assigned but not valid. If you want to ensure that + # it is both present and valid, you also need to use +validates_associated+. + # # Configuration options: # * <tt>:message</tt> - A custom error message (default is: "can't be blank"). # * <tt>:on</tt> - Specifies the contexts where this validation is active. diff --git a/guides/rails_guides/levenshtein.rb b/guides/rails_guides/levenshtein.rb index 36183fd321..049f633258 100644 --- a/guides/rails_guides/levenshtein.rb +++ b/guides/rails_guides/levenshtein.rb @@ -14,10 +14,13 @@ module RailsGuides d = (0..m).to_a x = nil - str1.each_char.each_with_index do |char1,i| + # avoid duplicating an enumerable object in the loop + str2_codepoint_enumerable = str2.each_codepoint + + str1.each_codepoint.with_index do |char1, i| e = i+1 - str2.each_char.each_with_index do |char2,j| + str2_codepoint_enumerable.with_index do |char2, j| cost = (char1 == char2) ? 0 : 1 x = [ d[j+1] + 1, # insertion diff --git a/guides/source/action_view_overview.md b/guides/source/action_view_overview.md index e76158e259..abf6c0db11 100644 --- a/guides/source/action_view_overview.md +++ b/guides/source/action_view_overview.md @@ -376,32 +376,6 @@ config.action_controller.asset_host = "assets.example.com" image_tag("rails.png") # => <img src="http://assets.example.com/images/rails.png" alt="Rails" /> ``` -#### register_javascript_expansion - -Register one or more JavaScript files to be included when symbol is passed to javascript_include_tag. This method is typically intended to be called from plugin initialization to register JavaScript files that the plugin installed in `vendor/assets/javascripts`. - -```ruby -ActionView::Helpers::AssetTagHelper.register_javascript_expansion monkey: ["head", "body", "tail"] - -javascript_include_tag :monkey # => - <script src="/assets/head.js"></script> - <script src="/assets/body.js"></script> - <script src="/assets/tail.js"></script> -``` - -#### register_stylesheet_expansion - -Register one or more stylesheet files to be included when symbol is passed to `stylesheet_link_tag`. This method is typically intended to be called from plugin initialization to register stylesheet files that the plugin installed in `vendor/assets/stylesheets`. - -```ruby -ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion monkey: ["head", "body", "tail"] - -stylesheet_link_tag :monkey # => - <link href="/assets/head.css" media="screen" rel="stylesheet" /> - <link href="/assets/body.css" media="screen" rel="stylesheet" /> - <link href="/assets/tail.css" media="screen" rel="stylesheet" /> -``` - #### auto_discovery_link_tag Returns a link tag that browsers and feed readers can use to auto-detect an RSS or Atom feed. @@ -1361,10 +1335,6 @@ date_field_tag "dob" Provides functionality for working with JavaScript in your views. -#### define_javascript_functions - -Includes the Action Pack JavaScript libraries inside a single `script` tag. - #### escape_javascript Escape carrier returns and single and double quotes for JavaScript segments. diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index d215d8b30f..8b6d70f1ad 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -916,8 +916,8 @@ TIP: In any case, Rails will not create foreign key columns for you. You need to ##### `:primary_key` -By convention, Rails assumes that the `id` column is used to hold the primary key of it's table. -The `:primary_key` option allows you to specify a different column. +By convention, Rails assumes that the `id` column is used to hold the primary key +of its tables. The `:primary_key` option allows you to specify a different column. For example, given we have a `users` table with `guid` as the primary key. If we want a separate `todos` table to hold the foreign key `user_id` in the `guid` column, then we can use `primary_key` to achieve this like so: @@ -931,7 +931,8 @@ class Todo < ActiveRecord::Base end ``` -When we execute `@user.todos.create` then the `@todo` record will have `user_id` value as the `guid` value of `@user`. +When we execute `@user.todos.create` then the `@todo` record will have its +`user_id` value as the `guid` value of `@user`. ##### `:inverse_of` diff --git a/guides/source/initialization.md b/guides/source/initialization.md index c0c8b7d4b6..199545a3b3 100644 --- a/guides/source/initialization.md +++ b/guides/source/initialization.md @@ -34,7 +34,7 @@ Launch! Let's start to boot and initialize the app. A Rails application is usually started by running `rails console` or `rails server`. -### `railties/bin/rails` +### `railties/exe/rails` The `rails` in the command `rails server` is a ruby executable in your load path. This executable contains the following lines: @@ -45,7 +45,7 @@ load Gem.bin_path('railties', 'rails', version) ``` If you try out this command in a Rails console, you would see that this loads -`railties/bin/rails`. A part of the file `railties/bin/rails.rb` has the +`railties/exe/rails`. A part of the file `railties/exe/rails.rb` has the following code: ```ruby diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index e60feed15f..6a14649853 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Rename `railties/bin` to `railties/exe` to match the new Bundler executables convention. + + *Islam Wazery* + * Print `bundle install` output in `rails new` as soon as it's available Running `rails new` will now print the output of `bundle install` as diff --git a/railties/bin/rails b/railties/exe/rails index 82c17cabce..82c17cabce 100755 --- a/railties/bin/rails +++ b/railties/exe/rails diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 341291f08b..a7da92168d 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -267,10 +267,13 @@ module Rails d = (0..m).to_a x = nil - str1.each_char.each_with_index do |char1,i| + # avoid duplicating an enumerable object in the loop + str2_codepoint_enumerable = str2.each_codepoint + + str1.each_codepoint.with_index do |char1, i| e = i+1 - str2.each_char.each_with_index do |char2,j| + str2_codepoint_enumerable.with_index do |char2, j| cost = (char1 == char2) ? 0 : 1 x = [ d[j+1] + 1, # insertion diff --git a/railties/railties.gemspec b/railties/railties.gemspec index 001882fdc6..7cb1f1a49c 100644 --- a/railties/railties.gemspec +++ b/railties/railties.gemspec @@ -15,10 +15,10 @@ Gem::Specification.new do |s| s.email = 'david@loudthinking.com' s.homepage = 'http://www.rubyonrails.org' - s.files = Dir['CHANGELOG.md', 'README.rdoc', 'RDOC_MAIN.rdoc', 'bin/**/*', 'lib/**/{*,.[a-z]*}'] + s.files = Dir['CHANGELOG.md', 'README.rdoc', 'RDOC_MAIN.rdoc', 'exe/**/*', 'lib/**/{*,.[a-z]*}'] s.require_path = 'lib' - s.bindir = 'bin' + s.bindir = 'exe' s.executables = ['rails'] s.rdoc_options << '--exclude' << '.' diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 63209559d7..4509797da1 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -322,7 +322,7 @@ Module.new do environment = File.expand_path('../../../../load_paths', __FILE__) require_environment = "-r #{environment}" - `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/railties/bin/rails new #{app_template_path} --skip-gemfile --no-rc` + `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/railties/exe/rails new #{app_template_path} --skip-gemfile --no-rc` File.open("#{app_template_path}/config/boot.rb", 'w') do |f| f.puts "require '#{environment}'" f.puts "require 'rails/all'" diff --git a/railties/test/railties/generators_test.rb b/railties/test/railties/generators_test.rb index 7348d70c56..423ece277e 100644 --- a/railties/test/railties/generators_test.rb +++ b/railties/test/railties/generators_test.rb @@ -30,7 +30,7 @@ module RailtiesTests if File.exist?("#{environment}.rb") require_environment = "-r #{environment}" end - `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/railties/bin/rails #{cmd}` + `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/railties/exe/rails #{cmd}` end def build_engine(is_mountable=false) |