Commit Graph

79137 Commits

Author SHA1 Message Date
Daniel Colson ff1623afcc
Merge pull request #41236 from andrewculver/fix-delegated-types-example
Fixing delegated types example.
2021-01-25 12:47:14 -05:00
Gannon McGibbon f15f494127
Merge pull request #41165 from davidstosik/webpacker-nitpicks
Add cosmetic improvements to the Webpacker guide
2021-01-25 12:46:21 -05:00
Andrew Culver 6298bcd44b
Fixing delegated types example. 2021-01-25 12:17:39 -05:00
Eugene Kenny 8329a9a494
Merge pull request #41230 from orhantoy/fix-typo
Fix typo [ci skip]
2021-01-25 12:22:47 +00:00
David Stosik 31ad146c16 Add small improvements to the Webpacker guide
- fix typos like double spaces, accidental caps
- improve some HTML links by giving them a label
- etc
2021-01-25 16:31:20 +09:00
Ryuta Kamizono c9effca029
Merge pull request #41228 from yboulkaid/remove-globalize
Remove reference to globalize gem from I18n guide

[ci skip]
2021-01-25 16:30:38 +09:00
Gannon McGibbon 76e37e29d8
Merge pull request #41220 from andrehjr/fix-generators-doc
Fix doc: stylesheet_include_tag -> stylesheet_link_tag
2021-01-25 02:00:39 -05:00
Orhan Toy 37cdf40c68 Fix typo [ci skip] 2021-01-25 06:46:23 +01:00
Sean Doyle 48e601c7a1 Move ActiveStorage fixture hooks to on_load
In a test environment, rely on the loading of
`:active_support_test_case`.

Introduce the `:active_record_fixture_set` hook for the Active Storage
engine to listen for during the load process in a development
environment (like when running `db:fixtures:load`).

Since this commit moves the task-aware path resolution out of the block
that provided local variables, it recreates part of the fixture
directory path resolution logic.
2021-01-25 00:36:37 -05:00
Cecile Veneziani 1b67adb819 Improve ActiveRecord strict_loading documentation
Apply the same structure as the documentation of `validate` option by
starting the description with "when set to true". This implies, that
the value passed to the option should be a boolean.
2021-01-24 22:35:40 +01:00
Youssef Boulkaid 46b8d343d3 Remove reference to globalize gem 2021-01-24 20:10:09 +01:00
Sean Doyle 948e9d74e3
Fix Flaky ActiveStorage test (#41225)
Fixes a flaky Active Storage test introduced by [rails/rails#41065][],
and improves the documentation.

It seems that the test is covering the backwards compatibility of an
older interface for retrieving records through
`ActiveStorage::Record#find_signed!`. The test itself would pass
unpredictably. To isolate the failure and reproduce it consistently, a
see value was found after some trial and error:

```
SEED=59729 bin/test test/fixture_set_test.rb test/models/attachment_test.rb
```

This _used_ to pass consistently because [rails/rails][#41065]
introduced a call to `fixtures :all`, which introduces more variation in
the database's ID generation sequence. Without that line, `id` values
start at `1`, so the fact that calls to
`ActiveStorage::Attached::One#id` and `ActiveStorage::Blob#id` **both
return `1`** is purely coincidence.

The proposed resolution changes the test slightly. Prior to this change,
the identifier used during retrieval and verification fetched from
`@user.avatar.id`, where `@user.avatar` is an instance of
`ActiveStorage::Attached::One`. The verifier/retriever combination in
that test expected a signed identifier for an `ActiveStorage::Blob`
instance. The change involved retrieving an instance through
`@user.avatar.blob`.

To better emphasize how global the `fixtures :all` declaration is, move
it from the `test/fixture_set_test.rb` file to the `test/test_helper.rb`
file.

[rails/rails#41065]: https://github.com/rails/rails/pull/41065
2021-01-24 18:29:11 +01:00
Tony Drake 9182b90a58 Guides: Missing erb tags for stylesheet_pack_tag [ci skip]
The section on needing to use `stylesheet_pack_tag` was lacking the erb
%'s.

I updated the markdown to actually show the helper being used with erb
as well as improve the wording of the sentence.
2021-01-24 11:57:41 -05:00
Sean Doyle 0ad777cdcc
Improve ActionText::FixtureSet documentation (#41062)
* Improve ActionText::FixtureSet documentation

Support for Action Text attachments in fixtures was added by [76b33aa][] and
released as part of [6.1.1][], but has not yet been documented.

This commit documents the `ActionText::FixtureSet` for the API
documentation, and mentions it in the Rails Guides pages.

[76b33aa]: 76b33aa3d1
[6.1.1]: https://github.com/rails/rails/releases/tag/v6.1.1

* Fix indention of comments

Co-authored-by: David Heinemeier Hansson <david@loudthinking.com>
2021-01-24 11:16:27 +01:00
Sean Doyle c0f33b923b
Improve Fixture support for Active Storage (#41065)
* Improve Fixture support for Active Storage

Inspired by [76b33aa][], this commit extends the Active Storage
documentation to elaborate on how to declare fixtures.

In support of that, also introduce the `ActiveStorage::FixtureSet.blob`
method for injecting in-line [ActiveStorage::Blob][] attributes directly
into fixture YAML.

[76b33aa]: 76b33aa3d1
[ActiveStorage::Blob]: https://edgeapi.rubyonrails.org/classes/ActiveStorage/Blob.html

* Extra CR for style

* Two-space indention

* Explaining variable didn't explain, inline for style

Co-authored-by: David Heinemeier Hansson <david@loudthinking.com>
2021-01-24 11:10:30 +01:00
Ryuta Kamizono b32823a7ec
Merge pull request #41223 from janko/controller-throw-log-subscriber
Handle throwing in controller action in log subscriber
2021-01-24 18:15:47 +09:00
Janko Marohnić 53adf53bc5
Handle throwing in controller action in log subscriber
When throw was used in a controller action, and there is matching catch
around the request in a Rack middleware, then :exception won't be
present in the event payload.

This is because ActiveSupport::Notifications::Instrumenter.instrument
sets :exception in a rescue handler, but rescue is never called in a
throw/catch scenario:

  catch(:halt) do
    begin
      throw :halt
    rescue Exception => e
      puts "rescue" # never reached
    ensure
      puts "ensure"
    end
  end

Missing :exception was actually handled prior to Rails 6.1.0, but an
optimization updated the code to assume this was present. So this can be
considered a regression fix.
2021-01-24 09:52:27 +01:00
Daniel Colson 66b861f24c
Restore ActiveStorage::Blob#find_signed
Rails 6.0 had a [public `find_signed` method][docs], but we changed it
to `find_signed!` in 31148cd6be.

This commit adds back `find_signed` alongside `find_signed!` to match
the corresponding [Active Record methods][].

[docs]: https://api.rubyonrails.org/v6.0.0/classes/ActiveStorage/Blob.html#method-c-find_signed
[Active Record methods]: https://github.com/rails/rails/blob/main/activerecord/lib/active_record/signed_id.rb#L42-L66
2021-01-23 23:14:48 -05:00
Ryuta Kamizono 1536a2bddb Remove wrong usage for `arel_table` [ci skip]
This usage doesn't work properly (missing `where`, undefined `published`,
`arel_table` in the scope definition accidentally lose table alias).
2021-01-24 10:40:21 +09:00
Ryuta Kamizono ac6527cc4a
Merge pull request #41224 from houhoulis/webpacker_guide_code_block_fix
Fix code block in Webpacker Guide [ci skip]
2021-01-24 10:28:43 +09:00
Chris Houhoulis a15b230fff Fix code block in Webpacker Guide [ci skip]
Formatting fix: the example directory tree listing was bleeding into the
previous paragraph and had extraneous characters due to a missing
newline.
2021-01-23 19:04:20 -05:00
André Luis Leal Cardoso Junior a141d741b1 Fix doc: stylesheet_include_tag -> stylesheet_link_tag 2021-01-23 13:07:58 -03:00
Étienne Barrié 142ae54e54 Allow jobs to rescue all exceptions
Before this commit, only StandardError exceptions can be handled by
rescue_from handlers.

This changes the rescue clause to catch all Exception objects, allowing
rescue handlers to be defined for Exception classes not inheriting from
StandardError.

This means that rescue handlers that are rescuing Exceptions outside of
StandardError exceptions may rescue exceptions that were not being
rescued before this change.

Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
2021-01-23 08:35:51 -05:00
Abhay Nikam 4762721d03 Fixes strict_loading! documentation
- Fixes typo in the changelog for strict_loading.
- Fixes the example in the changelog for strict_loading. The `strict_loading!` on ActiveRecord object does not disable strict loading on the association if set to strict loading. The example spoke otherwise so updated in a manner to make it more clear.
- Add method level dcoumentation as changelog was only way to communicate how strict_loading could be disabled on the record.
2021-01-23 16:29:52 +05:30
Ryuta Kamizono af9c910db7 `start_with?` allows multiple prefix values 2021-01-23 16:43:01 +09:00
Ryuta Kamizono 58ccc09d83
Merge pull request #41206 from intrip/41198-fix-current-page-kwargs
Fix current_page? with kwargs on ruby3
2021-01-23 15:53:09 +09:00
André Luis Leal Cardoso Junior 2fafcd84f4 Remove media=all from stylesheet_link_tag on generators 2021-01-22 21:27:47 -03:00
André Luis Leal Cardoso Junior 1280620767 Remove legacy media=screen default from stylesheet_link_tag.
If the media attribute is omitted, the default for web browsers is "all", meaning that by default links apply to all media.

Before:

```ruby
> stylesheet_link_tag "style"
=> <link href="/assets/style.css" media="screen" rel="stylesheet" />
```

After:

```ruby
> stylesheet_link_tag "style"
=> <link href="/assets/style.css" rel="stylesheet" />

```

The current behavior is not going to change for existing applications.

For newly built applications, the media attribute is not going to be added by default. Which can be configured using the following:

```
Rails.application.config.action_view.stylesheet_media_default = false
```
2021-01-22 20:42:22 -03:00
Gannon McGibbon 35ff70c0c0
Merge pull request #41183 from ghiculescu/patch-4
Update test docs in "contributing to Rails" guide [ci skip]
2021-01-22 17:57:52 -05:00
Alex Ghiculescu 70fe2c0f23 Update test docs in "contributing to Rails" guide
Updated guide to recommend `bin/test` and show examples of its use in different contexts.

Co-authored-by: Marivaldo Cavalheiro <marivaldo@gmail.com>
2021-01-22 15:54:46 -07:00
Eileen M. Uchitelle c9e4af5c9d
Merge pull request #41207 from Aguardientico/ar-structure-load-dump-configurable
Support hash config for `structure_dump_flags` and `structure_load_flags` flags
2021-01-22 16:02:02 -05:00
Gustavo Gonzalez 62aec5146b Support hash config for `structure_dump_flags` and `structure_load_flags` flags
Now that Active Record supports multiple databases configuration
    we need a way to pass specific flags for dump/load databases since
    the options are not the same for different adapters.
    We can use in the original way:
    ```ruby
    ActiveRecord::Tasks::DatabaseTasks.structure_dump_flags = ['--no-defaults', '--skip-add-drop-table']
    #or
    ActiveRecord::Tasks::DatabaseTasks.structure_dump_flags = '--no-defaults --skip-add-drop-table'
    ```
    And also use it passing a hash, with one or more keys, where the key
    is the adapter
    ```ruby
    ActiveRecord::Tasks::DatabaseTasks.structure_dump_flags = {
      mysql2: ['--no-defaults', '--skip-add-drop-table'],
      postgres: '--no-tablespaces'
    }
    ```
2021-01-22 15:42:46 -05:00
Rafael Mendonça França aec71e84d8
Merge pull request #41144 from malomalo/ar_adapter_config_with_url
AR connection configuration accepts `url` as a key if `adapter` is set
2021-01-22 20:25:39 +00:00
Jon Bracy 29cad39bd5
Connection specification now passes the "url" key to the adapter
If the "url" protocol is "jdbc", "http", or "https" the url option will
be passed to the adapter. Previously only urls with the "jdbc" prefix
were passed to the Active Record Adapter, others are assumed to be
adapter specification urls.

Fixes #41137.
2021-01-22 20:24:33 +00:00
Rafael França 03d3a1b994
Merge pull request #41188 from ijlee2/improve-getting-started
A few continuity improvements to Getting Started page [ci skip]
2021-01-22 14:08:37 -05:00
Gannon McGibbon a4e11e02a1
Merge pull request #41162 from ghiculescu/patch-2
Webpacker guide: remove Basecamp reference + fix broken links [docs] [skip-ci]
2021-01-22 14:06:50 -05:00
eileencodes b92374d962
Fix unintialized instance variable connection_class
This was throwing a warning when the test suite is run. Adding an
reader fixes the issue.
2021-01-22 13:32:55 -05:00
Xavier Noria 76c834bcb6
Merge pull request #41161 from ghiculescu/patch-1
Add Webpacker to Guides list
2021-01-22 14:37:50 +01:00
Xavier Noria 2604b2bc8e
Update documents.yaml 2021-01-22 14:37:15 +01:00
eileencodes 6f0f9e086a
Merge branch 'fixed_connected_to' into main 2021-01-22 07:56:09 -05:00
alpaca-tc 1cd08410a0
`connected_to` shouldn't be called on the abstract class that not established connection
Fixed: https://github.com/rails/rails/issues/40559#issuecomment-752056106

When abstract class hasn't own connections, calling `AbstractClass.connection`
returns parent class's connection. We call `AbstractClass.connection.preventing_writes?`
expecting abstract class's state to be returned, but actually it is parent's one.

I think that it isn't expected behavior so I prevents call `connected_to` on the abstract
class that not established the connection.
2021-01-22 07:52:15 -05:00
Jacopo 3d76418b9d Fix current_page? with kwargs on ruby3
Prevent raising an error when `options` are given as
kwargs, this is done by overriding `options` with kwargs
if `options` are `nil`; this implies that if both `options` and
kwargs are given, `options` takes precedence.

Fixes #41198
2021-01-22 12:16:16 +01:00
ijlee2 74e3e7986f Added a new line after the include statement 2021-01-22 07:56:28 +01:00
Ryuta Kamizono a96dd50033
Merge pull request #41208 from ttilberg/patch-1
Update name of input in tip to match example [ci skip]
2021-01-22 15:24:10 +09:00
Tim Tilberg 6210565e14
Update name of input to fix typo 2021-01-21 23:48:32 -06:00
Rafael França 15ed2cbe32
Merge pull request #40392 from shioyama/remove_respond_to_unsafe_method
Don't bother checking if strings respond to string methods
2021-01-21 19:00:35 -05:00
Rafael Mendonça França 1993496d7f
Upgrade all the gems to make sure we are testing with the latest versions locally 2021-01-21 21:22:41 +00:00
Rafael França 41f43560cc
Merge pull request #41205 from jonathanhefner/notes-command-resolve-default-annotations
Resolve default annotation tags after config loads
2021-01-21 16:15:58 -05:00
Jonathan Hefner ad25006216 Resolve default annotation tags after config loads
`Rails::SourceAnnotationExtractor::Annotation.tags` may be modified by
app configuration.  Therefore, resolve default annotation tags after
loading the app configuration.

This fixes errors like https://buildkite.com/rails/rails/builds/74268#240d60bc-baa7-4b6e-ad21-b3172095f939/1083-1092
resulting from erikhuda/thor@0222fe52ed.
2021-01-21 14:56:19 -06:00
Rafael Mendonça França 166960cfe7
Fix the benchmark script to point to the main branch 2021-01-21 20:29:12 +00:00