Skip to content
Permalink
Branch: master
Commits on Jul 5, 2018
  1. Shorter code: remove unnecessary condition

    claudiob committed Jul 5, 2018
    See 136fc65#r28897107
    
     I _think_ that this method can now be rewritten from:
    
    ```ruby
    def attribute_previous_change(attr)
      previous_changes[attr] if attribute_previously_changed?(attr)
    end
    ```
    
    to:
    
    ```ruby
    def attribute_previous_change(attr)
      previous_changes[attr]
    end
    ```
    
    without losing performance.
    
    ---
    
    Calling
    
    ```ruby
    previous_changes[attr] if attribute_previously_changed?(attr)
    ```
    
    is equivalent to calling
    
    ```ruby
    previous_changes[attr] if previous_changes.include?(attr)
    ```
    
    When this commit 136fc65 was made, Active Record had its own `previous_changes` method, added here below. However, that method has been recently removed from the codebase, so `previous_changes` is now only the method defined in Active Model as:
    
    ```ruby
    def previous_changes
      @previously_changed ||= ActiveSupport::HashWithIndifferentAccess.new
      @previously_changed.merge(mutations_before_last_save.changes)
    end
    ```
    
    Since we are dealing with a memoized Hash, there is probably no need to check `if .include?(attr_name)` before trying to fetch `[attr]` for it.
    
    Does that make sense? Did I miss anything? Thanks!
Commits on May 9, 2018
  1. Merge pull request #32835 from trezona-lecomte/ar_dirty_doc_fix

    claudiob committed May 9, 2018
    Fix ActiveRecord::AttributeMethods::Dirty documentation
Commits on Apr 4, 2018
  1. Add #dig to ActionDispatch::Request::Session

    claudiob authored and sinsoku committed Feb 24, 2016
    ### Summary
    
    The `session` object is not a real Hash but responds to many methods of Hash
    such as `[]`, `[]`, `fetch`, `has_key?`.
    
    Since Ruby 2.3, Hash also supports a `dig` method.
    
    This commit adds a `dig` method to `ActionDispatch::Request::Session` with the
    same behavior as `Hash#dig`.
    
    This is useful if you store a hash in your session, such as:
    
    ```ruby
    session[:user] = { id: 1, avatar_url: "http://example.org/nyancat.jpg" }
    ```
    
    Then you can shorten your code from `session[:user][:avatar_url]` to `session.dig :user, :avatar_url`.
    
    ### Other Information
    
    I cherry-picked a commit from #23864, and modify a bit.
    The changes are below:
    
    * Converts only the first key to a string adjust to the `fetch` method.
    * Fixes a test case because we cannot use the indifferent access since ee5b621.
Commits on Feb 13, 2018
  1. Don't overwrite config/master.key even on --force

    claudiob committed Feb 13, 2018
    See #31957 (comment)
    
    The purpose of `--force` is not to have any prompt whether a file should
    be kept or overwritten. In general, all existing files should be overwritten.
    However, `config/master.key` is special because it is git-ignored, and
    overwriting it will cause the app not to run (since there won't be a way
    to decrypt the credentials).
    
    As a result, it's probably better to keep the existing config/master.key.
Commits on Feb 11, 2018
  1. Respect --force option for config/master.key

    claudiob committed Feb 11, 2018
    This is similar to #30700 which ensures the `--quiet` option of `rails new`
    is respected by the `MasterKeyGenerator` (missing from #30067).
    
    Before this commit, running `rails new app --force` would still prompt the
    user what to do with the conflict in `config/master.key`:
    
    ```
                  …
       identical  config/locales/en.yml
        conflict  config/master.key
    Overwrite /Users/claudiob/Desktop/pizza/config/master.key? (enter "h" for help) [Ynaqdh]
    ```
    
    After this commit, `config/master.key` is overwritten:
    
    ```
               …
    identical  config/locales/en.yml
        force  config/master.key
       append  .gitignore
    ```
    
    The newly added test generates an app and then generates it again with
    `--force`. Without this commit, the test would just wait forever for user
    input.
Commits on Feb 10, 2018
  1. Merge pull request #31949 from rails/remove-move

    claudiob committed Feb 10, 2018
    Remove warning from 4 years ago [ci skip]
  2. Remove warning from 4 years ago [ci skip]

    claudiob committed Feb 10, 2018
    `config/initializers/assets.rb` has been a part of Rails apps since
    Rails 4.2 (30b5608). This comment is probably unnecessary by now.
Commits on Feb 8, 2018
  1. Add docs on how to configure Active Storage

    claudiob authored and georgeclaghorn committed Feb 8, 2018
    [ci skip]
Commits on Jan 30, 2018
  1. Merge pull request #31828 from claudiob/doc-csp

    claudiob committed Jan 30, 2018
    Add ContentSecurityPolicy to list of middleware
  2. Add ContentSecurityPolicy to list of middleware

    claudiob committed Jan 30, 2018
    Document in the guides the new middleware added in #31162
    [ci skip]
Commits on Dec 21, 2017
  1. Help if Active Storage tables are missing

    claudiob committed Dec 21, 2017
    When a user tries to create a new attachment or blog and the matching table is missing from the database
    (`active_storage_attachments` and `active_storage_blobs` by default), an informative error is displayed
    that invites users to run the `active_storage:install` task.
Commits on Dec 15, 2017
  1. Merge pull request #31481 from claudiob/fix-ast-guides

    claudiob committed Dec 15, 2017
    [ci skip] Use :amazon, not :s3, so that guides reflect the current code
  2. [ci skip] Use :amazon, not :s3, to reflect code

    claudiob committed Dec 15, 2017
    The [template](https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/app/templates/config/storage.yml.tt#L10)
    that generates the `config/storage.yml` file has the Amazon S3 key specified as `:amazon`, not `:s3`.
    
    The guides should reflect the nomenclature, given that every other service also
    has the name of the company as the key (:google, :microsoft).
  3. Don't run rails active_storage:install in new apps

    claudiob committed Dec 8, 2017
    See #31315 for full discussion
Commits on Dec 9, 2017
  1. Merge pull request #31354 from maciej-ka/docs-link_to-nil-name-example

    claudiob committed Dec 9, 2017
    docs: add example for a nil name in link_to
Commits on Dec 2, 2017
  1. Fix typo in test error message

    claudiob committed Dec 2, 2017
    With the current code, a failing test shows this error, which is missing
    the number of times called and has two periods at the end.
    
    ```
    /railties$ be ruby -Itest test/generators/app_generator_test.rb -n test_active_storage_install
    
    Failure:
    AppGeneratorTest#test_active_storage_install [test/generators/app_generator_test.rb:313]:
    active_storage:install expected to be called once, but was called  times..
    Expected: 1
      Actual: 2
    ```
    
    After the fix, the error message looks correct:
    
    ```
    /railties$ be ruby -Itest test/generators/app_generator_test.rb -n test_active_storage_install
    
    Failure:
    AppGeneratorTest#test_active_storage_install [test/generators/app_generator_test.rb:313]:
    active_storage:install expected to be called once, but was called 2 times.
    Expected: 1
      Actual: 2
    ```
Commits on Sep 19, 2017
  1. Use credentials, not secrets, for Active Storage (#30650)

    claudiob authored and dhh committed Sep 19, 2017
    According to #30067:
    
    > This PR will deprecate secrets.yml* and instead adopt
    > config/credentials.yml.enc to signify what these secrets are specifically
    > for: Keeping API keys, database passwords, and any other integration
    > credentials in one place.
    
    [ci skip] since only comments are being edited.
Commits on Aug 8, 2017
  1. [ci skip] Prefer cookies.encrypted over signed (#30129)

    claudiob authored and dhh committed Aug 8, 2017
    In some examples and guides we are recommending to use code like:
    
    ```ruby
    verified_user = User.find_by(id: cookies.signed[:user_id])
    ```
    
    My suggestion is to use instead:
    
    ```ruby
    verified_user = User.find_by(id: cookies.encrypted[:user_id])
    ```
    
    which invites users to prefer the "newer" encrypted cookies over the
    "legacy" signed cookies.
Commits on Aug 4, 2017
  1. `module ActiveStorage`, not `ActiveStorage::Class`

    claudiob committed Aug 4, 2017
    The reasons for this commit are:
    
    - uniformity with the other Rails libraries
    - (possibly) behave better with respect to autoloading
    - fix the index in the generated documentation
    
    Before this commit, run `rake rdoc` generates this left sidebar
    (ActiveStorage entries are indexed twice, both inside and outside the module):
    
    <img width="308" alt="before" src="https://user-images.githubusercontent.com/10076/28939523-7c087dec-7846-11e7-9289-38ed4a2930cd.png">
    
    After this commit, run `rake rdoc` generates this left sidebar:
    (ActiveStorage entries are only indexed inside the module):
    
    <img width="303" alt="after" src="https://user-images.githubusercontent.com/10076/28939524-7c090be0-7846-11e7-8ee5-29dfecae548e.png">
  2. Fix tests for AWS buckets that include a . (#30059)

    claudiob authored and dhh committed Aug 4, 2017
    If an AWS bucket name includes a `.` (e.g. `bucket.name`), then the canonical
    URL for an object will start with "https://s3.amazonaws.com/bucket.name/"
    and not with "https://bucket.name.s3.amazonaws.com/".
    
    The URL tests have now been separated into two separate asserts, to ensure
    that both the "s3.amazonaws.com" and the "bucket.name" components are included,
    but not specifically in that order.
  3. Add Active Storage to README and release (#30065)

    claudiob authored and dhh committed Aug 4, 2017
    Before we forget...
Commits on Aug 3, 2017
  1. Make Rubocop happier about ActiveStorage

    claudiob committed Aug 3, 2017
    Running `rubocop activestorage` before this commit resulted in 20 offenses.
    This commit only fixes:
    
    - Trailing whitespace detected
    - Space inside } missing
    - Put one space between the method name and the first argument.
    
    The other offenses are left since they are intentional according to
    @georgeclaghorn (#30061 (comment))
Commits on Aug 1, 2017
  1. Don't depend on HTTParty

    claudiob committed Aug 1, 2017
    "httparty" is only added in #30020 to write two tests to make PUT requests
    against S3 and GCS.
    
    The same requests can be made with net/http, removing a dependency from the Gemfile.
  2. Let ActiveStorage tests pass only for Disk

    claudiob committed Aug 1, 2017
    If you have a "service/configurations.yml" file, but every single line is
    commented out, then an error occurs when running tests:
    
    ```
    git:active-storage-import~/code/rails/activestorage$ rake
    ~/code/rails/activestorage/test/test_helper.rb:17:in `<top (required)>': undefined method `deep_symbolize_keys' for false:FalseClass (NoMethodError)
    	from ~/code/rails/activestorage/test/controllers/direct_uploads_controller_test.rb:1:in `require'
    ```
    
    The reason is that `YAML.load(..an empty file content..)` simply returns `false`, and not `{}`.
    
    This PR fixes this behavior so tests can also run when no remote service
    is available.
Commits on Apr 28, 2017
  1. 5.1 Release Notes are complete [ci skip]

    claudiob committed Apr 28, 2017
    @prathamesh-sonpatki added the last missing commits in #28911.
Commits on Apr 26, 2017
  1. More release notes for Rails 5.1 [ci skip]

    claudiob committed Apr 26, 2017
    @dhh most changes that I mentioned in the talk were already there:
    https://speakerdeck.com/claudiob/rails-5-dot-1-upcoming-features
    
    I just added a few that were missing.
  2. Merge pull request #28894 from robin850/5-1-notes-fixes

    claudiob committed Apr 26, 2017
    Some improvements to the 5.1 release notes
Commits on Apr 7, 2017
Commits on Apr 4, 2017
  1. Merge pull request #28665 from claudiob/don-t-highlight-code-in-links

    claudiob committed Apr 4, 2017
    Don't highlight code in anchorlink [ci skip]
  2. Don't highlight code in anchorlink [ci skip]

    claudiob committed Apr 4, 2017
    Minor fix to #28662
Commits on Mar 23, 2017
  1. Remove -j (--javascript) option from `rails new`

    claudiob committed Mar 23, 2017
    The "-j" option was added 5 years ago (d9c39c3)
    when we wanted to support prototype-rails and jquery-rails.
    Prototype is not as popular and jQuery is not a requirement anymore.
    Still the "-j" option can be used to install *any* gem that ends in "-rails".
    
    This "might" open security issues and does not bring great benefits anymore.
    
    If you know which "-rails"-ending gem you want to install, you can manually
    add it to the Gemfile just like any other gem.
Commits on Mar 22, 2017
  1. List options for `rails new --webpack=WEBPACK`

    claudiob committed Mar 22, 2017
    When you type `rails new -h`, the `--database=DATABASE` options display
    this useful message:
    
    > Preconfigure for selected database (options: mysql/postgresql/sqlite3/oracle/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
    
    However, the `--webpack=WEBPACK` option only displays this:
    
    > Preconfigure for app-like JavaScript with Webpack
    
    so it's hard to know *which* values are valid for `WEBPACK`.
    
    This commit improves the help message to display:
    
    > Preconfigure for app-like JavaScript with Webpack (options: react/vue/angular)
    
    The implication of this commit is that the list needs to be manually updated
    whenever rails/webpacker adds support for a new framework.
    
    However, I don't imagine this list to change very frequently, and I think that
    the benefit of display the list to the users is greater than the hustle of
    updating the list when needed.
  2. Don't add a dummy API key to every new Rails app

    claudiob committed Mar 22, 2017
    Every new Rails app is currently generated with
    `Rails.application.secrets[:api_key]` set to `123`.
    
    This comes from a line in `config/secrets.yml` that, in my opinion,
    should be left commented out to only serve as a syntax example, rather
    than being actually set in every Rails app.
    
    Additionally, we might want to give a better example than `123`, since
    in the same file we are suggesting to
    
    > Make sure the secret is at least 30 characters and all random,
    > no regular words or you'll be exposed to dictionary attacks.
    
    The result of this commit is that `config/secrets.yml` will include something like:
    
    ```yaml
     # Shared secrets are available across all environments.
    
     # shared:
     #   api_key: f56930851993982510d5bd9236f4108f6fe7c15448f1c6923a51872e0dbae1a24d274b318abb6518b540dfb51079c61640885f607467e5ed1053849be7587d61
    ```
    
    rather than this:
    
    ```yaml
     # Shared secrets are available across all environments.
    
     shared:
       api_key: 123
    ```
Commits on Mar 21, 2017
  1. Remove 5.0.0 entry from 5.1.0 CHANGELOG [ci skip]

    claudiob committed Mar 21, 2017
    The entry for PR #25430 is currently present both in the CHANGELOG
    for Rails 5.0 and for Rails 5.1:
    
    https://github.com/rails/rails/blame/9d3a352777c2594123583b0bc02d0dd80f1e385b/railties/CHANGELOG.md#L61-L72
    
    Since the PR was backported to 5-0-stable in #25499, I believe it
    should be removed from the CHANGELOG of 5.1, otherwise it looks like
    something changed from 5.0 to 5.1
Commits on Mar 15, 2017
  1. Merge pull request #28420 from claudiob/changelog-skip-coffee

    claudiob committed Mar 15, 2017
    Add CHANGELOG entry for --skip-coffee [ci skip]
Older
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.