Database configurations are now objects almost everywhere, so we don't
need to fake access to a hash with `#default_hash` or it's alias `#[]`.
Applications should `configs_for` and pass `env_name` and `spec_name` to
get the database config object. If you're looking for the default for
the test environment you can pass `configs_for(env_name: "test", spec_name:
"primary")`. Change test to developement to get the dev config, etc.
`#default_hash` and `#[]` will be removed in 6.2.
Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
The max size here is designed around Ruby's Dir::Tmpname.create which
creates temporary filenames in the format
$TIMESTAMP-$PID-$RANDOM
I believe the previous value of this field was based on the assumption
that PIDs are 1-65535, which isn't necessarily the case on 64 bit Linux
systems, which can be up to 2**22.
$ uname -a
Linux zergling 5.4.11-arch1-1 #1 SMP PREEMPT Sun, 12 Jan 2020 12:15:27 +0000 x86_64 GNU/Linux
$ cat /proc/sys/kernel/pid_max
4194304
I've chosen a new value based on what I believe the largest possible
tempname is:
255 - "20200117-4194304-#{0x100000000.to_s(36)}.lock".length #=> 226
This allows deprecation messages to be matched by substring, symbol (treated as
substring), or regular expression. If a warning is matched, the behaviors
configured for disallowed deprecations will be used. The default behavior for
disallowed deprecation warnings is `:raise`.
Also adds `ActiveSupport::Deprecation.allow` for thread-local, block level ignoring of deprecation warnings which would otherwise be disallowed by ActiveSupport::Deprecation.disallowed_warnings.
`helper_method` was taking `**kwargs` on all definitions by default.
ruby will assume that this means you want keyword args and call
`to_hash` on what you pass if the object responds to `to_hash`. Instead
we should only take keyword args if the helper method defined intends
to pass keyword args.
This also fixes a warning when you pass a hash to your helper method,
```
warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
```
Also, this would be a good candidate for using `...`, but since `send`
requires the method as the first argument, we can't use it here.
Currently, if you run `rails g migration remove_column_from_models`,
there is an empty line before `remove_column` line because we forgot to
use `-%>` in the template:
$ bin/rails g migration remove_title_from_posts title:string
invoke active_record
create db/migrate/20200114061235_remove_title_from_posts.rb
$ cat db/migrate/20200114061235_remove_title_from_posts.rb
class RemoveTitleFromPosts < ActiveRecord::Migration[6.1]
def change
remove_column :posts, :title, :string
end
end
This commit adds the missing `-` in front of `-%>` to make it removes
the empty line.
Follow up to 2bf1c17c20b3a2d053cba8db74b91acacaa62308, which still left
this one failure. Minitest 5.14 uses error instead of exception, so
exception had been changed to just be the same UnexpectedError instance
and losing us the actual error message.
This also switches to initializing a new UnexpectedError instance
because previously, for reasons I can't quite figure out, reusing the
same instance would still give us a DRbConnError.
Followup to 9256ae8a389fd40f9e4f152737de0fb2c6059daf.
Since the result of `as_json` is typically encoded with `to_json`, this
patch should save the same number of allocations as the previous one.