Commit Graph

78297 Commits

Author SHA1 Message Date
Balazs Varga
f4a6225357 Fix text_field_tag's placeholder documentation [ci skip]
When placeholder set to true on `text_field_tag`, it will try to look up its value from the translation files.
The documentation referenced an incorrect translation key scope, it is defined in [Placeholderable][1] as `helpers.placeholder` (singular).
Followup for #37054

Also improves wording.

[1]: 4640cff2b2/actionview/lib/action_view/helpers/tags/placeholderable.rb
2020-11-03 22:39:28 +01:00
Rafael Mendonça França
4640cff2b2
Fix regression when setting the invesion of a belongs_to relationship
This regression was added in c6f46564771413f4a06703fc6b1f82ed09a0c4c9.
What was happening is what when we were setting the belongs_to
associonation and the parent record already had one different child, the
inverted association was not being set.
2020-11-03 20:49:07 +00:00
Rafael Mendonça França
5d85d8822b
Fix documentation [ci skip] 2020-11-03 19:32:16 +00:00
Rafael França
f19d049976
Merge pull request #40526 from nburwell/doc/add_examples_to_active_record_ignored_columns
Add example usage pattern of ActiveRecord::Base.ignored_columns=
2020-11-03 14:31:46 -05:00
Takumi Shotoku
4e097556d3
[v6.1.0.rc1] Fix regression for select tag helper with array (#40522)
* Fix regression for select tag helper with array

v6.1.0.rc1 does not generate DOM with the selected attribute
when the object's method returns an array.
This is because it has been changed by #34809 to always convert
to a string.

This commit fixes the issue.

## Steps to reproduce

```ruby
# frozen_string_literal: true

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem "rails", ENV["RAILS_VERSION"]
end

require "action_view"
require "minitest/autorun"

class BugTest < ActionView::TestCase
  Post = Struct.new("Post", :tags)

  def test_stuff
    @post = Post.new
    @post.tags = ["foo", "bar"]
    expected = <<~DOM.strip
      <select name="post[tags]" id="post_tags"><option selected="selected" value="foo">foo</option>
      <option selected="selected" value="bar">bar</option>
      <option value="buz">buz</option></select>
    DOM

    assert_dom_equal(expected, select("post", "tags", %W(foo bar buz), { multiple: true }))
  end
end
```

The test succeeds on v6.0.3.4, but the test fails on v6.1.0.rc1.

* Update actionview/lib/action_view/helpers/tags/select.rb

[Takumi Shotoku + Rafael Mendonça França]
2020-11-03 13:27:51 -05:00
Eugene Kenny
bc524f16ee
Merge pull request #40517 from eugeneius/depend_on_message
Use LoadError#original_message if available in depend_on
2020-11-03 18:12:24 +00:00
Nick Burwell
69a982f1b4 Add example usage pattern of ActiveRecord::ModelSchema.ignored_columns= to rdoc 2020-11-03 10:12:00 -08:00
Eileen M. Uchitelle
4ac10dc5aa
Merge pull request #40512 from tahsin352/th_test_timestamp_string
Create unit test to use to_time for timestamp in string
2020-11-03 08:56:34 -05:00
Eileen M. Uchitelle
b0fbc93520
Merge pull request #40524 from hahmed/ha/fix-formatting-in-multiple-db-docs
Fix formatting issue in multiple db docs [ci-skip]
2020-11-03 08:56:05 -05:00
Haroon Ahmed
96b1c65a6c Fix formatting issue with multuple db docs 2020-11-03 13:51:25 +00:00
Tahsin Hasan
a52ca5fddc Create unit test to use to_time for timestamp in string 2020-11-03 18:51:43 +06:00
eileencodes
22584d0cbf
Fix documentation for sharded dbs
This said that it writing to shard one but it's actually writing in
the default shard.
2020-11-03 07:42:02 -05:00
Ryuta Kamizono
b1150dda28
Merge pull request #40520 from akinomaeni/update-change-log-for-inspect-time-attributes
[ci skip] Update CHANGELOG for inspect time attributes
2020-11-03 20:49:49 +09:00
Ryuta Kamizono
9f38121db9 Remove extra class [ci skip]
Follow up to #40523.
2020-11-03 20:20:57 +09:00
Kasper Timm Hansen
ed7eb0f275
Merge pull request #40523 from edudepetris/patch-1
remove extra class [ci skip]
2020-11-03 12:03:03 +01:00
Edu Depetris
03043ab07c
remove extra class [ci skip] 2020-11-03 23:49:24 +13:00
akinomaeni
e67bf020e9 [ci skip] Update CHANGELOG for inspect time attributes
to match the change in #39169
2020-11-03 14:19:13 +09:00
Rafael Mendonça França
8389f9902c
Preparing for 6.1.0.rc1 release 2020-11-02 21:12:47 +00:00
Eugene Kenny
94ab712585 Use LoadError#original_message if available in depend_on
did_you_mean 1.5.0 will add suggestions to `LoadError`. This means that
`LoadError#message` will now return a new string on each invocation, and
mutating the result will no longer modify the error's message.
2020-11-02 20:54:29 +00:00
Rafael Mendonça França
81ee5dcdf4
Merge pull request #39538.
Closes #39538.
2020-11-02 20:42:40 +00:00
Vipul A M
fdfac8760f
Although libraries support both formats of sign before and after DIGITS(ex: https://github.com/moment/luxon/pull/683, https://github.com/moment/moment/issues/2408), many do not.
For example PG refers to https://www.ietf.org/rfc/rfc3339.txt when converting(Ref: https://www.postgresql.org/docs/current/datatype-datetime.html)

According to the ref there is no explicit mention of allowing sign before the parts, which reads as below:

 Durations:

    dur-second        = 1*DIGIT "S"
    dur-minute        = 1*DIGIT "M" [dur-second]
    dur-hour          = 1*DIGIT "H" [dur-minute]
    dur-time          = "T" (dur-hour / dur-minute / dur-second)
    dur-day           = 1*DIGIT "D"
    dur-week          = 1*DIGIT "W"
    dur-month         = 1*DIGIT "M" [dur-day]
    dur-year          = 1*DIGIT "Y" [dur-month]
    dur-date          = (dur-day / dur-month / dur-year) [dur-time]

    duration          = "P" (dur-date / dur-time / dur-week)

We should not attempt to move sign forward in this case.
2020-11-02 20:41:48 +00:00
Rafael França
890035fd4a
Merge pull request #40365 from ankurp/fix/standardize-js-package-name
Follow npm/JS standard for package name
2020-11-02 15:29:41 -05:00
Eugene Kenny
67e69e8db4
Merge pull request #38829 from cbisnett/host_authorization_exclude
Add request exclusion to Host Authorization
2020-11-02 20:22:35 +00:00
Rafael França
5f40eca4a5
Merge pull request #39832 from p8/scaffold-generator-inflection-check
Raise if camelcase inflection impossible in generator
2020-11-02 15:18:26 -05:00
Chris Bisnett
1f767407cb Add request exclusion to Host Authorization
In the same way that requests may need to be excluded from forced SSL,
requests may also need to be excluded from the Host Authorization
checks. By providing this additional flexibility more applications
will be able to enable Host Authorization while excluding requests
that may not conform. For example, AWS Classic Load Balancers don't
provide a Host header and cannot be configured to send one. This means
that Host Authorization must be disabled to use the health check
provided by the load balancer. This change will allow an application
to exclude the health check requests from the Host Authorization
requirements.

I've modified the `ActionDispatch::HostAuthorization` middleware to
accept arguments in a similar way to `ActionDispatch::SSL`. The hosts
configuration setting still exists separately as does the
hosts_response_app but I've tried to group the Host Authorization
settings like the ssl_options. It may make sense to deprecate the
global hosts_response_app if it's only used as part of the Host
Authorization failure response. I've also updated the existing tests
as the method signature changed and added new tests to verify the
exclusion functionality.
2020-11-02 20:16:29 +00:00
Eugene Kenny
872e757145
Merge pull request #40421 from ayamomiji/master
Fix rename_index removing old index with symbols
2020-11-02 20:09:34 +00:00
Kasper Timm Hansen
473a6500e7
Merge pull request #40515 from p8/sdoc-2.0.0
Use official sdoc gem instead of fork [skip ci]
2020-11-02 21:04:17 +01:00
Petrik
f9ae061bfd Use official sdoc gem instead of fork [skip ci] 2020-11-02 20:58:37 +01:00
Eugene Kenny
56c9be11ad Tidy up comments in environment configuration files [ci skip]
https://guides.rubyonrails.org/api_documentation_guidelines.html#wording
2020-11-02 19:51:58 +00:00
Eugene Kenny
b7eaaf73fb Update comment about reloading in development.rb [ci skip]
This comment predates the existence of `reload_classes_only_on_change`.
2020-11-02 19:36:26 +00:00
Eileen M. Uchitelle
bd28db1400
Merge pull request #40510 from eileencodes/add-connected_to_many
Add `connected_to_many` API
2020-11-02 14:34:57 -05:00
Nate Berkopec
7547a6b073
Mark Reaper thread as fork-safe w/thread-local variable (#40399)
Re: https://github.com/rails/rails/issues/37066#issuecomment-709403972

Puma (and some other multi-threaded application servers) may check the `Thread` list before and after forking to look for any threads that may have been running during a call to `fork`. Threads running during a `fork` can leave memory and resources open and potentially cause leaks or deadlocks.

However, the Reaper thread in ActiveRecord cannot orphan any resources or memory, and will be cleaned up after forking.

Setting this thread local variable allows Puma and other application servers to ignore this thread for the purpose of displaying warnings to users about threads present and running during `fork`.

Co-authored-by: Eugene Kenny <elkenny@gmail.com>
2020-11-02 18:39:27 +00:00
eileencodes
27d51da866
Add connected_to_many API
Now that we have implemented granular connection swapping in #40370
we need a new API that will allow connections to multiple databases. The
reason we need this API is it will prevent deep nesting in cases where
we know that we want 3 of our 5 databases to connect to reading and
leave the rest on writing.

With this API, instead of writing:

```ruby
AnimalsRecord.connected_to(role: :reading) do
  MealsRecord.connected_to(role: :reading) do
    Dog.first # read from animals replica
    Dinner.first # read from meals replica
    Person.first # read from primary writer
  end
end
```

This API would allow you to write:

```ruby
ActiveRecord::Base.connected_to_many([AnimalsRecord, MealsRecord], role: :reading) do
  Dog.first # read from animals replica
  Dinner.first # read from meals replica
  Person.first # read from primary writer
end
```

This would come in especially handy for deeper nesting past 2 databases.

Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
2020-11-02 13:29:48 -05:00
Eileen M. Uchitelle
a7f29d357b
Merge pull request #40511 from eileencodes/add-option-for-handling-strict-loading
Allow applications to change the behavior for a strict loading violation
2020-11-02 13:26:36 -05:00
Rafael Mendonça França
7eed607b12
Fix CHANGELOG [ci skip] 2020-11-02 18:16:45 +00:00
Rafael França
af91d9a1c5
Merge pull request #40434 from filipe-sabella/pass-in-base-in-validation-messages
Pass in base to Error.human_attribute_names
2020-11-02 13:15:53 -05:00
Rafael Mendonça França
f8a1a8acc3
Merge pull request #39953
Closes #39953.
2020-11-02 18:12:11 +00:00
Edouard Chin
868866c1fd
Allow a new server Railtie block:
- This is similar to other railties blocks (such as `console`,
  `tasks` ...). The goal of this block is to allow the application
  or a railtie to load code after the server start.

  The use case can be to fire the webpack or react server in
  development or start some job worker like sidekiq or resque.

  Right now, all these tasks needs to be done in a separate
  shell and gem maintainer needs to add documentation on
  how to run their libraries if another program needs to run
  next to the Rails server.

  This feature can be used like this:

  ```ruby
    class SuperRailtie < Rails::Railtie
      server do
        WebpackServer.run
      end
    end
  ```
2020-11-02 18:11:41 +00:00
eileencodes
656c6faf78
Allow applications to change the behavior for a strict loading violation
Originally strict loading violations would always raise an error if
turned on for an association. This change allows for an application to
optionally log instead of raise. The behavior here is similar to how
strong parameters work. By default all environments will raise. An
application may want to use log in production while working on finding
all lazily loaded associations.

Set `config.active_record.action_on_strict_loading_violation` to `:log`
in your application to log instead of raise.
2020-11-02 13:01:50 -05:00
Rafael Mendonça França
4dd61b4318
Prepare the maintenance policy to match the 6.1 release
[ci skip]
2020-11-02 18:00:47 +00:00
Jonathan Hefner
71f743ffdd
Merge pull request #40500 from jonathanhefner/guides-irb-code-fences
Use irb code fences where applicable [ci-skip]
2020-11-02 11:56:34 -06:00
Jonathan Hefner
9f7d2656fa
Merge pull request #40481 from jonathanhefner/guide-getting_started-rework
Rework Getting Started guide [ci-skip]
2020-11-02 11:55:48 -06:00
Rafael França
0300aa802a
Merge pull request #40504 from tbrisker/paramobjects
Reduce object allocations in param wrapping
2020-11-02 12:52:24 -05:00
Rafael França
d52ece70f0
Merge pull request #40492 from nateberkopec/puma5
Upgrade Puma to 5.x
2020-11-02 12:48:32 -05:00
Rafael França
7f912ba27e
Merge pull request #40513 from jonathanhefner/tweak-generated-filter_parameters
Tweak generated default filter_parameters
2020-11-02 12:46:52 -05:00
Jonathan Hefner
b38c2c1a84 Tweak generated default filter_parameters
Follow-up to #34218.

This removes some filters that could filter innocuous fields such as
`author_name`.  Filtering such fields might be surprising, especially to
people generating their first Rails app.

This commit also changes the `:password` filter to `:passw` so that it
can also filter fields such as `passwd`.
2020-11-02 10:12:32 -06:00
eileencodes
3c99817394
Fix broken sqlite3_mem tests
I put this test in the wrong place and it broke the sqlite3_mem tests.
This test shouldn't run on sqlite3_mem.
2020-11-02 10:44:57 -05:00
eileencodes
9c8a7f4308
Fix while_preventing_writes for legacy version
We need to pass the block along to the connection handler's
`while_preventing_writes`.
2020-11-02 09:22:12 -05:00
eileencodes
0919871bda
Add tests for current_preventing_writes
Ensure that the new version and legacy versions work as expected.
2020-11-02 09:21:15 -05:00
eileencodes
197b1bbc1a
Reorder code and add docs to current_* methods
Reorders the methods since we usually go role, shard, then prevent
writes. I think it makes it easier to read.

Added documention to the methods for `current_shard` and
`current_preventing_writes`. These were originally marked as `nodoc` but
that doesn't make sense, apps may need to call these so we should make
them public.
2020-11-02 09:19:22 -05:00