1. 22 3月, 2018 1 次提交
  2. 21 3月, 2018 2 次提交
  3. 20 3月, 2018 1 次提交
    • D
      Expose foreign key name ignore pattern in configuration · d3fd4e4e
      David Stosik 提交于
      When dumping the database schema, Rails will dump foreign key names only
      if those names were not generate by Rails. Currently this is determined
      by checking if the foreign key name is `fk_rails_` followed by
      a 10-character hash.
      
      At [Cookpad](https://github.com/cookpad), we use
      [Departure](https://github.com/departurerb/departure) (Percona's
      pt-online-schema-change runner for ActiveRecord migrations) to run migrations.
      Often, `pt-osc` will make a copy of a table in order to run a long migration
      without blocking it. In this copy process, foreign keys are copied too,
      but [their name is prefixed with an underscore to prevent name collision
      ](https://www.percona.com/doc/percona-toolkit/LATEST/pt-online-schema-change.html#cmdoption-pt-online-schema-change-alter-foreign-keys-method).
      
      In the process described above, we often end up with a development
      database that contains foreign keys which name starts with `_fk_rails_`.
      That name does not match the ignore pattern, so next time Rails dumps
      the database schema (eg. when running `rake db:migrate`), our
      `db/schema.rb` file ends up containing those unwanted foreign key names.
      This also produces an unwanted git diff that we'd prefer not to commit.
      
      In this PR, I'd like to suggest a way to expose the foreign key name
      ignore pattern to the Rails configuration, so that individual projects
      can decide on a different pattern of foreign keys that will not get
      their names dumped in `schema.rb`.
      d3fd4e4e
  4. 19 3月, 2018 9 次提交
  5. 18 3月, 2018 3 次提交
  6. 17 3月, 2018 5 次提交
    • G
      Merge pull request #32275 from elainefang/fix-grammar · ef73318e
      George Claghorn 提交于
      Fix grammar in Getting Started with Rails
      ef73318e
    • E
      Fix grammar in Getting Started with Rails · aa8f51b9
      ef718 提交于
      aa8f51b9
    • E
      Merge pull request #32271 from eileencodes/fix-three-tier-default-connection · 9700dacf
      Eileen M. Uchitelle 提交于
      Fix default connection handling with three-tier config
      9700dacf
    • E
      Switch dbconsole config loader check · 4027643f
      eileencodes 提交于
      In a three-tier config environment
      `configurations[environment].presence` will return `{ :primary => {
      :key => value, :key => value }, :secondary => { :key => value, :key =>
      value} }, which means it's not given a single config to connect to.
      
      If we flip these however it will connect to primary because that's the
      default connection, and on a two tier it will be `nil` so the code will
      select the connection from the configurations rather than the
      connection.
      4027643f
    • E
      Fix connection handling with three-tier config · 03929463
      eileencodes 提交于
      If you had a three-tier config, the `establish_connection` that's called
      in the Railtie on load can't figure out how to access the default
      configuration.
      
      This is because Rails assumes that the config is the first value in the
      hash and always associated with the key from the environment. With a
      three tier config however we need to go one level deeper.
      
      This commit includes 2 changes. 1) removes a line from `resolve_all`
      which was parsing out the the environment from the config so instead of
      getting
      
      ```
      {
        :development => {
          :primary => {
            :database => "whatever"
          }
        },
          :animals => {
            :database => "whatever-animals"
          }
        },
        etc with test / prod
      }
      ```
      
      We'd instead end up with a config that had no attachment to it's
      envioronment.
      
      ```
      {
        :primary => {
          :database => "whatever"
        }
        :animals => {
          :database => "whatever-animals"
        }
        etc - without test and prod
      }
      ```
      
      Not only did this mean that Active Record didn't know how to establish a
      connection, it didn't have the other necessary configs along with it in
      the configs list.
      
      So fix this I removed the line that deletes these configs.
      
      The second thing this commit changes is adding this line to
      `establish_connection`
      
      ```
      spec = spec[spec_name.to_sym] if spec[spec_name.to_sym]
      ```
      
      When you have a three-tier config and don't pass any hash/symbol/env etc
      to `establish_connection` the resolver will automatically return both
      the primary and secondary (in this case animals db) configurations.
      We'll get an `database configuration does not specify adapter` error
      because AR will try to establish a connection on the `primary` key
      rather than the `primary` key's config. It assumes that the
      `development` or default env automatically will return a config hash,
      but with a three-tier config we actually get a key and config `primary
      => config`.
      
      This fix is a bit of a bandaid because it's not the "correct" way to
      handle this situation, but it does solve our immediate problem. The new
      code here is saying "if the config returned from the resolver (I know
      it's called spec in here but we interchange our meanings a LOT and what
      is returned is a three-tier config) has a key matching the "primary"
      spec name, grab the config from the spec and pass that to the
      estalbish_connection method".
      
      This works because if we pass `:animals` or a hash, or `:primary` we'll
      already have the correct configuration to connect with.
      
      This fixes the case where we want Rail to connect with the default
      connection.
      
      Coming soon is a refactoring that should eliminate the need to do this
      but I need this fix in order to write the multi-db rake tasks that I
      promised in my RailsConf submission. `@tenderlove` and I are working on
      the refactoring of the internals for connection management but it won't
      be ready for a few weeks and this issue has been blocking progress.
      03929463
  7. 16 3月, 2018 8 次提交
  8. 15 3月, 2018 4 次提交
  9. 14 3月, 2018 7 次提交
    • A
      Merge pull request #32250 from... · b3b193f7
      Andrew White 提交于
      Merge pull request #32250 from bogdanvlviv/add-info-about-exprity-of-siigned-cookies-to-upgrading-to-5-2
      
      Update "Upgrading from Rails 5.1 to Rails 5.2" [ci skip]
      b3b193f7
    • B
      Update "Upgrading from Rails 5.1 to Rails 5.2" [ci skip] · c8a22bb9
      bogdanvlviv 提交于
      Add section "Expiry in signed or encrypted cookie is now embedded in the cookies values"
      to `master` since it should always be in the guides, not only for version 5.2.
      
      Add info about `config.action_dispatch.use_authenticated_cookie_encryption`
      to the "Configuring Rails Applications" guide.
      
      It was committed straight  to `5-2-stable` since we don't need this
      functionality in 6.0. Related to b25fcbc0.
      c8a22bb9
    • A
      Pass the skip_pipeline option in image_submit_tag · ae7a5720
      Andrew White 提交于
      Fixes #32248.
      ae7a5720
    • B
      Partly revert #32231 · 10cc0680
      bogdanvlviv 提交于
      - Remove extra execution of `perform_enqueued_jobs`
        since it performs all enqueued jobs in the duration of the block.
      - Fix example of using `assert_emails` without block since we
        can't use enqueued jobs in this case.
      10cc0680
    • Y
      a489cc81
    • K
      Fix routing inspector tests broken in... · f7e7fdc5
      Kasper Timm Hansen 提交于
      Fix routing inspector tests broken in https://github.com/rails/rails/commit/6629d51a2756fadf961bb09df20579cacfef2c8e
      
      * Renames grep_pattern to grep throughout.
      * Fixes setup not calling super by calling setup with a block.
      * Converts test helper method to a private one, like we have it other places.
      * Uses keyword arguments to get around awkward draw({ grep: "x" }, Action…)
        construction.
      f7e7fdc5
    • K
      Rely on Rails::Command's help output. · 6629d51a
      Kasper Timm Hansen 提交于
      We end up with:
      
      ```
      Usage:
        bin/rails routes [options]
      
      Options:
        -c, [--controller=CONTROLLER]      # Filter by a specific controller, e.g. PostsController or Admin::PostsController.
        -g, [--grep=GREP]                  # Grep routes by a specific pattern.
        -E, [--expanded], [--no-expanded]  # Print routes expanded vertically with parts explained.
      ```
      
      which does miss the bit about routes being printed in order.
      
      Also:
      
      * Renames options to ease help output readability, then clarifies each option.
      * Fixes a bunch of indentation.
      6629d51a