Commit Graph

75257 Commits

Author SHA1 Message Date
Kyohei Toyoda
07533a3d2f Add method to confirm rich text content existence by adding ? after content name
This change introduces a rich text object to make
it easier to confirm it context is existing or not.

If we have a class like below.

class Information < ApplicationRecord
  has_rich_text :notes
end

Before:
i = Information.new
i.notes? => NoMethodError
i.notes = "Some sample text"
i.notes.present? => true

After:
i = Information.new
i.notes? => false

i.notes = "Some sample text"
i.notes? => true
2019-12-13 12:58:42 +09:00
Kasper Timm Hansen
ff299f1741
Set default directly with default: 2019-12-13 02:09:08 +01:00
Kasper Timm Hansen
5ded839cfb
Strip default_ prefix from retry_jitter config to match conventions 2019-12-13 01:42:58 +01:00
Carlos Antonio da Silva
8739729072
Merge pull request #37947 from liljack/rails-documentation-contribution
Clarify documentation by removing charged words [ci skip]
2019-12-12 19:56:46 -03:00
Kasper Timm Hansen
2bcf24795b
Merge pull request #37928 from CGA1123/fix-race-in-action-view
Make ActionView::LookupContext::DetailsKey thread-safe
2019-12-12 22:47:30 +01:00
Mark McDonald
16e77e4975 Reorder active support instrumentation guide (#37639)
* Keep consistent verb tenses

[ci skip]

* Add link to "creating your own events"

[ci skip]

* Move section on how to subscribe to events above list of events

The list of events is really long, and most people only care about a
specific event or type of event.

[ci skip]
2019-12-12 22:40:29 +01:00
Aaron Patterson
fa292703e1
Merge pull request #37075 from woahdae/fix-multiple-choice-route-options
Fix route from "(:a)(foo/:b)" when only given :b
2019-12-12 12:34:30 -08:00
Aaron Patterson
285cc00128
Merge pull request #37073 from woahdae/fix-hierarchical-route-options
Fix route from "(:a)(:b)" when given only :a or :b
2019-12-12 12:25:19 -08:00
Kevin Jacoby
b0743dda8c Clarify documentation by removing charged words
Using words such as 'just', 'simply' and 'easy' implies to the reader
that the tasks they are trying to accomplish are tasks that anyone can
do, which might then frustrate them if they find it difficult to
complete.

This commit rephrases some usage of these words to aid understanding in
the readers without making them feel belittled.

[ci skip]
2019-12-12 19:43:51 +00:00
Eileen M. Uchitelle
cad13033fc
Merge pull request #37847 from pwim/action-mailbox-mail-ext-tests
Test extensions to Mail gem
2019-12-12 10:15:07 -05:00
Eileen M. Uchitelle
477ec2675d
Merge pull request #37939 from joelhawksley/class_names-changelog
Add changelog entry for https://github.com/rails/rails/pull/37918
2019-12-11 16:08:33 -05:00
Joel Hawksley
e1545682eb
Add changelog entry for https://github.com/rails/rails/pull/37918
Per request from @bogdanvlviv.
2019-12-11 09:20:38 -07:00
Vipul A M
f185190a7a
Merge pull request #37936 from s-mori/fix_typo_in_ar_dirty
Fix typo in ActiveRecord::AttributeMethods::Dirty
2019-12-11 19:53:41 +05:30
s-mori
ce0b8ffbd6 [ci skip] Fix typo, will_save_change_to_attribute -> will_save_change_to_attribute? 2019-12-11 23:02:38 +09:00
Ryuta Kamizono
42111f85df
Merge pull request #37924 from itohiro73/improve_contributing_guide_for_rdoc
Improve contributing guide for RDoc [ci skip]
2019-12-11 11:11:29 +09:00
Ryuta Kamizono
c727d30f51
Merge pull request #37931 from giraffate/remove_unused_requires
Remove unused requires
2019-12-11 10:36:31 +09:00
Takayuki Nakata
d0bd3cdc06 Remove unused requires
`reporting` was removed at 7e75dc5d86.
`singleton_class` was removed at b342d2baef.
2019-12-11 10:07:27 +09:00
Eileen M. Uchitelle
ab6f7f756f
Merge pull request #37926 from eileencodes/move-records-and-loaded-ivar-to-load
Move records and loaded ivar up to load
2019-12-10 15:14:11 -05:00
eileencodes
847643a55a Move records and loaded ivar up to load
We should set the `@records` and `@loaded` ivar inside `#load` rather
than in `#exec_queries`. Since `#load` is running `#exec_queries` and
`@records` can only be assigned if `loaded?` is true and `@loaded` can
only be set if `loaded?` is true then `#load` should do the assignment.
This is cleaner but also we came across this while working on an
internal gem and realized that the ivar assignment was happening in the
wrong place.

Co-authored-by: Aaron Patterson <aaron.patterson@gmail.com>
2019-12-10 14:15:11 -05:00
Eileen M. Uchitelle
19c5bd38f4
Merge pull request #37923 from cpruitt/add-config-for-activejob-retry-jitter
Add ActiveJob::Base.default_retry_jitter config option to specify jitter value
2019-12-10 14:09:58 -05:00
eileencodes
25daafbc00 Revert "Merge pull request #37798 from Edouard-chin/ec-sqlite3-connection-transaction"
This reverts commit b4ab1f19d8bcc4639c7379b560f000f01753b5b0, reversing
changes made to 9926fd86626690746c7ee78174c4d3577bdfa58d.

This is causing CI to fail about 50% of the time, and can be reproduced
locally 100% of the time on my machine.

Ex failing build https://buildkite.com/rails/rails/builds/65467#efaa1dd5-aaf4-43a1-a204-d1c42abf614d

Error:

```
SQLite3::BusyException: database is locked (ActiveRecord::StatementInvalid)
```
2019-12-10 14:07:03 -05:00
Cliff Pruitt
64649cec8b Add explaination of default_retry_jitter to configuring guide 2019-12-10 12:11:46 -05:00
Cliff Pruitt
e2cdffce3d Add config option for ActiveJob::Base.default_retry_jitter 2019-12-10 12:11:46 -05:00
Hiroshi Ito
4bed3337f4 Improve contributing guide for RDoc [ci skip] 2019-12-10 23:33:14 +09:00
Eileen M. Uchitelle
774e77c2cc
Merge pull request #37918 from joelhawksley/class_names_helper
Introduce class_names helper
2019-12-10 09:27:37 -05:00
Eileen M. Uchitelle
e36097a950
Merge pull request #37919 from joelhawksley/controller-render-in
Render objects that respond_to render_in in controllers
2019-12-10 09:18:26 -05:00
Eileen M. Uchitelle
836fbf2f86
Merge pull request #37921 from hmtanbir/37829-fix-docs-about-etag
Fix docs about etag
2019-12-10 09:16:03 -05:00
Tanbir Hasan
15365de5a4
Fix docs about etag 2019-12-10 15:55:16 +06:00
Joel Hawksley
20a83f52d7
Render objects that respond_to render_in in controllers
In https://github.com/rails/rails/pull/36388,
we supported passing objects that `respond_to` `render_in`
to `render`, but _only_ in views.

This change does the same for controllers, as Rails
generally gives the expectation that `render` behaves
the same in both contexts.

Co-authored-by: Aaron Patterson <tenderlove@github.com>
2019-12-09 16:43:18 -07:00
Joel Hawksley
f24734a7e1
Introduce class_names helper
As a follow-up to https://github.com/rails/rails/pull/37872,
this change introduces a class_names view helper
to make it easier to conditionally apply class names
in views.

Before:
<div class="<%= item.for_sale? ? 'active' : '' %>">

After:
<div class="<%= class_names(active: item.for_sale?) %>">

We've been using this helper in the GitHub monolith
since 2016.

Co-authored-by: Aaron Patterson <tenderlove@github.com>
2019-12-09 16:41:18 -07:00
Joel Hawksley
4fbb1e9f5b
Add test case 2019-12-09 15:37:27 -07:00
Richard Schneeman
32b363b246
Merge pull request #37738 from joshuaflanagan/allow_equals_in_db_url_query_value
Database URL supports query value with equal sign
2019-12-09 16:20:01 -06:00
Rafael França
2ab8364bde
Merge pull request #37916 from Edouard-chin/ec-fix-actionview-tag-option
Fix input value not properly applied:
2019-12-09 19:10:16 -03:00
Edouard CHIN
95bc8d0a23 Fix input value not properly applied:
- #37872 introduced a regression and you can't do

  ```html.erb
    hidden_field_tag('token', value: [1, 2, 3])
  ```

  This will result in a `<input type="hidden" value=""`>.

  I chose `hidden_field_tag` and the `value` attribute as an example
  but this issue applies to any tag helper and any attributes.

  https://github.com/rails/rails/pull/37872#issuecomment-561806468
  mention that the feature should only apply for "class" attribute.

  This commit fix original intent of #37872
2019-12-09 22:54:25 +01:00
Rafael Mendonça França
73e079a184
Merge pull request #35210 from pjrebsch/fix-joins-include-select
Retain selections with `includes` and `joins`
2019-12-09 15:28:46 -03:00
Joshua Flanagan
43a6420e17 Database URL supports query value with equal sign
A querystring value should be allowed to include an equal sign `=`.

This is necessary to support passing `options` for a PostgresSQL connection.

```

development:
  url: postgresql://localhost/railsdevapp_development?options=-cmysetting.debug=on
```

Before this PR, attempting to start the rails process with that configuration would result in an error:

```
> bundle exec rails console
Traceback (most recent call last):
	49: from bin/rails:4:in `<main>'
	48: from bin/rails:4:in `require'
...
	 1: from /rails/activerecord/lib/active_record/database_configurations/connection_url_resolver.rb:58:in `query_hash'
/rails/activerecord/lib/active_record/database_configurations/connection_url_resolver.rb:58:in `[]': invalid number of elements (3 for 1..2) (ArgumentError)
```

After this PR, rails can properly parse the configuration:

```
> bundle exec rails console
Loading development environment (Rails 6.1.0.alpha)
2.6.5 :001 > ActiveRecord::Base.connection.select_all("show mysetting.debug").to_a
   (0.4ms)  show mysetting.debug
 => [{"mysetting.debug"=>"on"}]
```
2019-12-09 12:11:58 -06:00
Rafael França
b4ab1f19d8
Merge pull request #37798 from Edouard-chin/ec-sqlite3-connection-transaction
Added posibility to open a `read_uncommitted` transaction on SQLite:
2019-12-09 14:32:53 -03:00
Rafael França
9926fd8662
Merge pull request #37827 from Edouard-chin/ec-activejob-enqueuing
Don't run AJ after_enqueue / after_perform when chain is halted:
2019-12-09 13:50:48 -03:00
Edouard CHIN
bbfab0b33a Don't run AJ after_enqueue / after_perform when chain is halted:
- ### Problem

  ```ruby
    MyJob < ApplicationJob
      before_enqueue { throw(:abort) }
      after_enqueue { # enters here }
    end
  ```
  I find AJ behaviour on after_enqueue and after_perform callbacks
  weird as they get run even when the callback chain is halted.
  It's counter intuitive to run the after_enqueue callbacks even
  though the job wasn't event enqueued.

  ### Solution

  In Rails 6.2, I propose to make the new behaviour the default
  and stop running after callbacks when the chain is halted.
  For application that wants this behaviour now or in 6.1
  they can do so by adding the `config.active_job.skip_after_callbacks_if_terminated = true`
  in their configuration file.
2019-12-09 17:17:23 +01:00
Rafael França
7f4d222c37
Merge pull request #37830 from Edouard-chin/ec-activejob-enqueue-and-perform-log
Fix ActiveJob logging when callback chain is halted:
2019-12-09 13:05:10 -03:00
Rafael Mendonça França
c12814173f
Add myself of codeowner of the rubocop config 2019-12-09 12:42:06 -03:00
Edouard CHIN
0d3aec4969 Fix ActiveJob logging when callback chain is halted:
- ### Problem

  ActiveJob will always log "Enqueued MyJob (Job ID) ..." even
  if the job doesn't get enqueued through the adapter.
  Same problem happens when performing a Job, "Performed MyJob (Job ID) ..." will be logged even when job wasn't performed at all.
  This situation can happen either if the callback chain is terminated
  (before_enqueue throwing an `abort`) or if an exception is raised.

  ### Solution

  Check if the callback chain is aborted/exception is raised, and  log accordingly.
2019-12-09 16:17:55 +01:00
Rafael Mendonça França
737fb59eb3
Fix Rubocop violation 2019-12-09 12:14:24 -03:00
Edouard CHIN
82e767f3d3 Don't assume all database in SQLite are files:
- SQlite allow database to be specified as URL (given that URI filename
  interpretation was turned on on the connection.)

  This commit is necessary for the read_uncommitted transaction
  feature because SQLite doesn't allow to enable the shared-cache mode
  if the database name is `:memory:`. It has to be a URI (`file::memory`)

  Ref https://www.sqlite.org/sharedcache.html#shared_cache_and_in_memory_databases
2019-12-09 15:56:44 +01:00
Edouard CHIN
cf5b6199df Added posibility to open a read_uncommitted transaction on SQLite:
- ### Use case

  I'd like to be able to see changes made by a connection writer
  within a connection reader before the writer transaction commits
  (aka `read_uncommitted` transaction isolation level).

  ```ruby
  conn1.transaction do
    Dog.create(name: 'Fido')
    conn2.transaction do
      Dog.find(name: 'Fido') # -> Can't see the dog untill conn1 commits the transaction
    end
  end
  ```

  Other adapters in Rails (mysql, postgres) already supports multiple
  types of isolated db transaction.
  SQLite doesn't support the 4 main ones but it supports
  `read_uncommitted` and `serializable` (the default one when opening
  a transaction)

  ### Solution

  This PR allow developers to open a `read_uncommitted` transaction by
  setting the PRAGMA `read_uncommitted` to true for the duration
  of the transaction. That PRAGMA can only be enabled if the SQLite
  connection was established with the [shared-cache mode](https://www.sqlite.org/sharedcache.html)

  This feature can also benefit the framework and we could potentially
  get rid of the `setup_shared_connection_pool` inside tests which
  was a solution in the context of a multi-db app so that the reader
  can see stuff from the open transaction writer but has some [caveats](https://github.com/rails/rails/issues/37765#event-2828609021).

  ### Edge case

  Shared-cache mode can be enabled for in memory database as well,
  however for backward compatibility reasons, SQLite only allows
  to set the shared-cache mode if the database name is a URI.
  It won't allow it if the database name is `:memory`; it has to be
  changed to `file::memory` instead.
2019-12-09 15:56:44 +01:00
Rafael Mendonça França
e67fdc5aeb
Revert "Merge pull request #37504 from utilum/no_implicit_conversion_of_nil"
This reverts commit 4e105385d046e2aeab16955943df97c5eefa3a6f, reversing
changes made to 62b43839098bbbbfc4be789128d33dc0612f1ab3.

The change in Ruby that made those changes required was reverted in
8852fa8760
2019-12-09 11:50:39 -03:00
Rafael França
7c3e4409fd
Merge pull request #37913 from kirikiriyamama/merge-shared-configuration-deeply
Rails::Application#config_for merges shared configuration deeply
2019-12-09 11:04:47 -03:00
kirikiriyamama
2b17c114eb Add CHANGELOG entry for 4d858b3f2a 2019-12-09 15:20:27 +09:00
kirikiriyamama
4d858b3f2a Merge shared configuration deeply 2019-12-08 22:18:08 +09:00
Dalto Curvelano
b4ee2d5f65 Update documentation for setting up database tests (#37475)
[ci skip]
2019-12-08 11:06:35 +09:00