Commit Graph

7075 Commits

Author SHA1 Message Date
Carlos Antonio da Silva
2a3f759eef Generate new apps with latest puma version 2019-08-21 08:41:41 -03:00
Rafael Mendonça França
04cfbc807f
Generate keep file in tmp/pids
Since 9c913116c634fe5fe2159a94b8f1a244801a4877, if you run `rackup`
in a machine that doesn't have that folder, the server will not start.

This doesn't happen on `rails s` because we create that folder when
starting the server on
8c8b02784a/railties/lib/rails/commands/server/server_command.rb (L70-L74).
2019-08-19 16:53:01 -04:00
Adam Renberg Tamm
af8751fcf8 Fix minor typo in rails/engine docs [ci skip] 2019-08-19 14:26:53 +02:00
utilum
271601ff65 constant Gem::RubyGemsVersion is deprecated
As of ruby/ruby@c4f7c260f9.

```
~/code/rails$ ruby -v
ruby 2.7.0dev (2019-08-17T03:32:34Z master dc020b06ff) [x86_64-linux]

/home/u/.rbenv/versions/2.7.0-dev/bin/ruby -w -Itest -Ilib
-I../activesupport/lib -I../actionpack/lib -I../actionview/lib
-I../activemodel/lib test/rails_info_controller_test.rb
/home/u/code/rails/railties/lib/rails/info.rb:71: warning: constant
Gem::RubyGemsVersion is deprecated

/home/u/.rbenv/versions/2.7.0-dev/bin/ruby -w -Itest -Ilib
-I../activesupport/lib -I../actionpack/lib -I../actionview/lib
-I../activemodel/lib test/rails_info_test.rb
/home/u/code/rails/railties/lib/rails/info.rb:71: warning: constant
Gem::RubyGemsVersion is deprecated

/home/u/.rbenv/versions/2.7.0-dev/bin/ruby -w -Itest -Ilib
-I../activesupport/lib -I../actionpack/lib -I../actionview/lib
-I../activemodel/lib test/application/routing_test.rb
Run options: --seed 26063

....../home/u/code/rails/railties/lib/rails/info.rb:71: warning:
constant Gem::RubyGemsVersion is deprecated
.................../home/u/code/rails/railties/lib/rails/info.rb:71:
warning: constant Gem::RubyGemsVersion is deprecated
.

```
2019-08-17 18:41:56 +02:00
Rafael Mendonça França
1953e0e1ac
Support Rails with sass-rails 6 2019-08-16 18:33:29 -04:00
Rafael França
4614848564
Merge pull request #36946 from eugeneius/return_only_media_type_on_content_type_new_default
Fix new default value for return_only_media_type_on_content_type
2019-08-15 20:26:19 -04:00
Ben Sheldon [he/him]
0c28bddf40
Remove lonely alignment whitespace from Puma config 2019-08-15 16:25:24 -07:00
Rafael França
9ad68a4cf1
Merge pull request #36803 from andrewkress/fix-issue-36799
read webpacker config to populate autoload paths
2019-08-15 18:53:47 -04:00
Eugene Kenny
582401ad73 Fix new default value for return_only_media_type_on_content_type
Uncommenting this line should opt applications in to the new behaviour;
in this case, `false` is the value needed to do that. This is the value
set when `config.load_defaults 6.0` is called:

5a4305f0ec/railties/lib/rails/application/configuration.rb (L133)
2019-08-15 21:09:41 +01:00
Andrew Kress
61c5a14cab rename to javascript_path, make attr_accessor 2019-08-14 12:36:27 -05:00
Andrew Kress
ffaee477bd create an attribute so that webpacker can set its default path instead of hardcoding 2019-08-13 15:20:59 -05:00
Xavier Noria
5a70f33909 defines Rails.autoloaders.log! 2019-08-13 18:14:50 +02:00
yuuji.yaginuma
6170a2a502 Remove feature policy initializer in API only apps
Because `FeaturePolicy::Middleware` is not loaded in API only apps.
Ref: 646dd8c51f/railties/lib/rails/application/default_middleware_stack.rb (L69-L72)
2019-08-08 17:47:07 +09:00
Kasper Timm Hansen
f1f5024b91
Revise flow to what was described in 03e44f9 2019-08-04 02:19:55 +02:00
Kasper Timm Hansen
03e44f9300
Revise credentials diffing flow to use a separate diff command
Didn't like the complicated stuff that happened on credentials:edit. It
would append to .gitattributes multiple times. Though I see why it was
written that way.

I'm cutting off for now, but since this new flow would require each developer
to run --enable perhaps this should really be:

1. Developer enrolls Rails app by running `credentials:diff --enable`
2. credentials:edit checks .gitattributes for `diff=rails_credentials` and
   if the current file is covered by that.
3. If so, set up the "rails_credentials" driver automatically.
2019-08-04 01:32:41 +02:00
Kasper Timm Hansen
6db2c426c0
Extract diffing to separate credentials:diff command 2019-08-04 00:00:16 +02:00
Kasper Timm Hansen
b4112f45b3
Commands already make fileutils available. 2019-08-03 23:19:14 +02:00
Kasper Timm Hansen
af2880bdda
Rename to Diffing and move module into credentials command
Helpers is more for sharing between commands. Since `Diffing` is only
for credentials we should just keep it only for credentials.

Replaces "pretty" with diffing since the former is ambiguous, while
diffing captures what it does. `opt_in` seemed clunky so it's swapped
for the one-word enable.
2019-08-03 23:06:47 +02:00
Rafael Mendonça França
1c7207a22f
1.hour needs core_ext to work
Usually the application requires the entire active support at load time
but the configuration happens before it is loaded. For that reason we
need to require the core_ext that we want to use in this file.
2019-08-02 15:02:59 -04:00
Daniel Colson
159a121044
Remove duplicate method definition
no_color! is already defined in [`Rails::Command::Behavior`][behavior],
which gets [included into `Rails:Generators`][include]. This duplication
came about in 6813edc7d9 when we introduced the Thor command structure.

We have [test coverage][] to ensure this method still behaves correctly
on `Rails:Generators`.

[behavior]: f7e91c7224/railties/lib/rails/command/behavior.rb (L12-L14)
[include]: f7e91c7224/railties/lib/rails/generators.rb (L18)
[test coverage]: f7e91c7224/railties/test/generators_test.rb (L163-L168)
2019-08-01 17:42:44 -04:00
Akira Matsuda
530f7805ed It may be better to explicitly require 'object/try' where we call try
In most cases it works now without explicit require because it's accidentally required through
active_support/core_ext/date_and_time/calculations.rb where we still call `try`,
but that would stop working if we changed the Calculations implementation and remove the require call there.
2019-08-01 18:51:51 +09:00
Ryuta Kamizono
4c8c8c87b0 Address to rubocop offences 2019-07-31 17:48:14 +09:00
meganemura
718c9e5e7f Remove redundant empty line when we don't use system test 2019-07-29 19:11:27 +09:00
Akira Matsuda
0196551e60 Use match? where we don't need MatchData 2019-07-29 14:23:10 +09:00
Akira Matsuda
0d981a2b3d Let the generated initializers/backtrace_silencers.rb code use Regexp#match? 2019-07-29 14:21:30 +09:00
Lachlan Campbell
f1cfe1ee70 Add viewport meta tag to default application template 2019-07-28 19:49:53 -04:00
Akira Matsuda
d1ffe59ab5 Use match? where we don't need MatchData
We're already running Performance/RegexpMatch cop, but it seems like the cop is not always =~ justice
2019-07-27 13:06:49 +09:00
Rafael França
ea4305109e
Merge pull request #36777 from Edouard-chin/ec-git-pretty-credentials
Prettify diff generated by git for encrypted file:
2019-07-26 14:18:14 -04:00
Edouard CHIN
5a4acf7ac4 Prettify diff generated by git for encripted file:
- @sinsoku had the idea and started implementing it few months ago
  but sadly didn't finish it.
  This PR is taking over his work.

  The credentials feature has changed a lot since @sinsoku opened hi
  PR, it was easier to just restart from scratch instead of checking
  out his branch.
  Sinsoku will get all the credit he deserves for this idea :)

  TL;DR on that that feature is to make the `git diff` or `git log`
  of encrypted files to be readable.

  The previous implementation was only setting up the git required
  configuration for the first time Rails was bootstraped, so I decided
  to instead provide the user a choice to opt-in for readable diff
  credential whenever a user types the `bin/rails credentials:edit`
  command.
  The question won't be asked in the future the user has already
  answered or if the user already opted in.

  Co-authored-by: Takumi Shotoku <insoku.listy@gmail.com>
2019-07-26 16:28:51 +02:00
y-yagi
65dcc9d159
Merge pull request #36747 from y-yagi/add_mention_about_collection_cache_versioning
Add mention about `active_record.collection_cache_versioning` to the `new_framework_defaults.rb`
2019-07-26 10:24:52 +09:00
John Hawthorn
d45507b931
Merge pull request #36731 from jhawthorn/dir_glob_base_instead_of_chdir
Use Dir.glob(base: ...) to avoid chdir
2019-07-25 16:31:08 -07:00
Andrew Kress
7f21e04e61 read configuration to determine excluded eager loaded directory (#36354)
* read config/webpacker.yml to determine which path to exclude for zeitwerk:check

* fix test errors

* more changes to fix test errors

* refactor webpacker_path

[Andrew Kress + Rafael Mendonça França]
2019-07-25 17:10:59 -04:00
Rafael França
0744e15a35
Merge pull request #34218 from eliotsykes/filter-common-sensitive-params
Add common sensitive names to generated filter parameters
2019-07-24 14:24:19 -04:00
yuuji.yaginuma
13e43a10bd Add mention about active_record.collection_cache_versioning to the new_framework_defaults.rb
All other recommended new configurations that set in `load_defaults` are
already mentioned in `new_framework_defaults.rb`.
So `active_record.collection_cache_versioning` should also be mentioned.
2019-07-24 20:00:25 +09:00
Rafael França
9c913116c6
Merge pull request #36542 from spk/add-pidfile-option-to-puma-conf
Add pidfile option to puma config template
2019-07-23 10:45:34 -04:00
John Hawthorn
13b2ca2031 Use Dir.glob(base: ...) to avoid chdir 2019-07-22 14:40:51 -07:00
Edouard CHIN
426d2f2502 Move the deprecation call after the new class has been defined:
- If we create the deprecation before the new class is defined this
  creates an issue in case you use a `TracePoint`. The
  `Tracepoint#return_value` will try to get the new class constant
  resulting in a uninitialized constant Rails::SourceAnnotationExtractor

  The problem can be reproduced like this:

  ```ruby
  @defined = Set.new

  ANONYMOUS_CLASS_DEFINITION_TRACEPOINT = TracePoint.new(:c_return) do |tp|
    next unless @defined.add?(tp.return_value)
  end

  ANONYMOUS_CLASS_DEFINITION_TRACEPOINT.enable

  require 'rails'
  require "rails/source_annotation_extractor"
  ```
2019-07-22 15:27:17 +02:00
masakazutakewaka
386c116fb4 create a newline between blocks when gem_group, github and add_source was called. 2019-07-21 21:04:01 -07:00
y-yagi
a390001bbe
Merge pull request #35285 from masakazutakewaka/fix_railtie_add_newline_to_gemfile_insertion
Add a newline at the end of a Gemfile when it doesn't end with a newline
2019-07-21 08:24:19 +09:00
George Claghorn
400b210354
Preserve existing attachment assignment behavior for upgraded apps
Assigning to a collection of attachments appends rather than replacing, as in 5.2. Existing 5.2 apps that rely on this behavior will no longer break when they're upgraded to 6.0.

For apps generated on 6.0 or newer, assigning replaces the existing attachments in the collection. #attach should be used to add new attachments to the collection without removing existing ones.

I expect that we'll deprecate the old behavior in 6.1.

Closes #36374.
2019-07-20 06:33:11 -04:00
masakazutakewaka
9147b284b6 Append a newline to the Gemfile if it doesn't end with a newline 2019-07-19 22:07:48 -07:00
Yuji Yaginuma
c5a24c8ebb
Merge pull request #36603 from y-yagi/add_skip_collision_check_option
Add `skip-collision-check` option to generator
2019-07-18 07:17:47 +09:00
Eileen M. Uchitelle
79ef8310be
Merge pull request #36663 from igor04/load_database_yaml_fix
Prevent exception of loading database yaml with blank config file
2019-07-15 09:11:36 -04:00
Jacob Bednarz
6c5acd5bc1
Use reserved domain for example configuration
Updates the generator output to use a reserved domain[1] instead of a
potentially real world domain.

[1]: https://tools.ietf.org/html/rfc2606#section-3
2019-07-15 08:16:51 +10:00
Xavier Noria
938d18d09a improves zeitwerk:check 2019-07-12 23:44:44 +02:00
igor04
0fa41f72fc Prevent exception of loading database yaml with blank config file [closes: #36661] 2019-07-12 19:23:09 +03:00
Xavier Noria
43ae74f6f6 make sure zeitwerk:check only deals with directories [closes #36461] 2019-07-12 18:11:58 +02:00
Akira Matsuda
84e21165a8 active_support/dependencies/autoload is already required via active_support.rb 2019-07-12 18:30:58 +09:00
Akira Matsuda
46ac8aceb3 These are already required via rails/command.rb 2019-07-12 18:28:53 +09:00
Jacob Bednarz
bf19b8774e Adds support for configuring HTTP Feature Policy (#33439)
A HTTP feature policy is Yet Another HTTP header for instructing the
browser about which features the application intends to make use of and
to lock down access to others. This is a new security mechanism that
ensures that should an application become compromised or a third party
attempts an unexpected action, the browser will override it and maintain
the intended UX.

WICG specification: https://wicg.github.io/feature-policy/

The end result is a HTTP header that looks like the following:

```
Feature-Policy: geolocation 'none'; autoplay https://example.com
```

This will prevent the browser from using geolocation and only allow
autoplay on `https://example.com`. Full feature list can be found over
in the WICG repository[1].

As of today Chrome and Safari have public support[2] for this
functionality with Firefox working on support[3] and Edge still pending
acceptance of the suggestion[4].

#### Examples

Using an initializer

```rb
# config/initializers/feature_policy.rb
Rails.application.config.feature_policy do |f|
  f.geolocation :none
  f.camera      :none
  f.payment     "https://secure.example.com"
  f.fullscreen  :self
end
```

In a controller

```rb
class SampleController < ApplicationController
  def index
    feature_policy do |f|
      f.geolocation "https://example.com"
    end
  end
end
```

Some of you might realise that the HTTP feature policy looks pretty
close to that of a Content Security Policy; and you're right. So much so
that I used the Content Security Policy DSL from #31162 as the starting
point for this change.

This change *doesn't* introduce support for defining a feature policy on
an iframe and this has been intentionally done to split the HTTP header
and the HTML element (`iframe`) support. If this is successful, I'll
look to add that on it's own.

Full documentation on HTTP feature policies can be found at
https://wicg.github.io/feature-policy/. Google have also published[5] a
great in-depth write up of this functionality.

[1]: https://github.com/WICG/feature-policy/blob/master/features.md
[2]: https://www.chromestatus.com/feature/5694225681219584
[3]: https://bugzilla.mozilla.org/show_bug.cgi?id=1390801
[4]: https://wpdev.uservoice.com/forums/257854-microsoft-edge-developer/suggestions/33507907-support-feature-policy
[5]: https://developers.google.com/web/updates/2018/06/feature-policy
2019-07-10 15:33:15 -07:00
yuuji.yaginuma
6fec4c3a0a Add skip-collision-check option to generator
Until Rails 5.2, generators can run same name multi times without destroying.
But Rails 6.0(with Zeitwerk) can't this. In Rails 6.0, an error occurs
due to class name collision check.

The check uses `const_defined?`, which assumes that the autoload object
is also defined.
https://ruby-doc.org/core-2.6.3/Module.html#method-i-const_defined-3F

It did not work until Rails 5.2, but Zeitwerk seems to be able to
correctly check this against the application's code.

However, this is a little inconvenient if want to run the generator
again like mistake an attribute name(need to run `destoy` before).

In order to solve this, this PR adds an option to skip the collision check.
With this option, you can overwrite files just as did until Rails 5.2.
2019-07-05 18:55:47 +09:00
Yuji Yaginuma
141b30630c
Merge pull request #36534 from y-yagi/fixes_35137
Add the ability to set the CSP nonce only to the specified directives
2019-07-03 08:23:48 +09:00
Tatsuya Hoshino
1466701fab Replace the www.robotstxt.org URL with https one [ci skip]
The robots.txt site is moved permanently to https URL.
2019-06-25 23:20:19 +09:00
Laurent Arnoud
36f3dd333b
Add pidfile option to puma config template
This allow to call `pumactl` directly without extra parameters needed
2019-06-23 16:33:55 +02:00
yuuji.yaginuma
09d55b3022 Add the ability to set the CSP nonce only to the specified directives
I changed to set CSP nonce to `style-src` directive in #32932.
But this causes an issue when `unsafe-inline` is specified to `style-src`
(If a nonce is present, a nonce takes precedence over `unsafe-inline`).

So, I fixed to nonce directives configurable. By configure this, users
can make CSP as before.

Fixes #35137.
2019-06-22 12:44:37 +09:00
yuuji.yaginuma
ddb6d788d6 Make ActionDispatch::Response#content_type behavior configurable
I changed return value of `ActionDispatch::Response#content_type` in #36034.
But this change seems to an obstacle to upgrading. https://github.com/rails/rails/pull/36034#issuecomment-498795893

Therefore, I restored the behavior of `ActionDispatch::Response#content_type`
to 5.2 and deprecated old behavior. Also, made it possible to control the
behavior with the config.
2019-06-21 07:17:14 +09:00
Ben Thorner
2e5ec9a6ef Allow using env var to specify pidfile
Previously it was only possible to specify the location of the pidfile
for the 'rails server' command with the '-P' flag. This adds support for
specifying the pidfile using a PIDFILE env var, which can still be
overridden by the '-P' flag and with the default pidfile path unchanged.

The motivation for this feature comes from using Docker to run multiple
instances of the same rails app. When developing a rails app with
Docker, it's common to bind-mount the rails root directory in the
running container, so that changes to files are shared between the
container and the host. However, this doesn't work so well with the
pidfile and it's necessary to (remember to) add a '-P' flag to the
'rails server' command line; being able to specify this flag using an
env var would make developing with Rails+Docker a bit simpler.
2019-06-19 14:06:38 +01:00
Ryuta Kamizono
c81af6ae72 Enable Layout/EmptyLinesAroundAccessModifier cop
We sometimes say "✂️ newline after `private`" in a code review (e.g.
https://github.com/rails/rails/pull/18546#discussion_r23188776,
https://github.com/rails/rails/pull/34832#discussion_r244847195).

Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style
`EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059).

That cop and enforced style will reduce the our code review cost.
2019-06-13 12:00:45 +09:00
yuuji.yaginuma
770f8f345f Remove redundant blank line at the bottom of the generated controller test 2019-06-07 15:18:44 +09:00
yuuji.yaginuma
689b371a52 Extract default log file open operation to method
This allows customize a default log file(e.g. `reopen`) by an application.

Fixes #32211.
2019-06-05 11:19:15 +09:00
yuuji.yaginuma
4cb0ce2e79 Fix rubocop violation 2019-06-05 10:37:03 +09:00
Eileen M. Uchitelle
61c3ea8c04 Merge pull request #36395 from cpruitt/6-0-stable
Do not clear deprecated initializer dependencies if using classic autoloader
2019-06-04 10:04:30 -04:00
yuuji.yaginuma
1ff98ed988 Remove spring-watcher-listen from default Gemfile
`spring-watcher-listen` watch application root by default.
c4bfe15805/lib/spring/watcher/listen.rb (L58)

This is necessary to watch the file (e.g. `.ruby-version`) in the
application root.

By this `node_modules` also be watched, and it is a possibility to be
shown a warning by `listen`.
Related to #32700, #34912, https://github.com/rails/webpacker/issues/1990.

`listen` watches directory recursive by default, and it cannot avoid it.
https://github.com/guard/listen/issues/111

So If this warning happens, the only workaround the user can do is remove
the gem.

The issue is likely to occur more frequently in Rails 6 because
`rails new` runs `webpacker:install` by default. Because of such a
state, I think that we should not recommend to use
`spring-watcher-listen`.

Spring has polling watcher, restart process works without this
`spring-watcher-listen`.
Because of polling base, CPU load may be higher than listen base. Still
I think that it is better than the warning comes out.
2019-06-02 10:32:53 +09:00
yuuji.yaginuma
784664f85b Bring after_bundle back to API document [ci skip]
At class level `:nodoc:` all elements are prevented. Instead, use
`:stopdoc:` / `:startdoc:` to make `after_bundle` appear.
2019-05-29 11:46:32 +09:00
Kasper Timm Hansen
a1c269fbdf
Skip needless spaces from generated app layout. 2019-05-26 23:02:37 +02:00
Anton Rieder
1fe26f7f8b
Bump Gemfile entry jbuilder version
jbuilder 2.6.4 is the first version that relaxes the version constraint to allow
Rails 6. I also did some more tests in #25183, although not with 2.6.4
explicitly.

To simplify the version requirement, I went for 2.7.

https://github.com/rails/jbuilder/blob/v2.6.4/jbuilder.gemspec
https://github.com/rails/rails/issues/25183#issuecomment-494342406
2019-05-23 17:21:34 +02:00
Vishal Telangre
ae9be13713
Fix: DummyCompiler embeds invalid YAML content
Fixes https://github.com/rails/rails/issues/36285.

Follow up of https://github.com/rails/rails/pull/36237.
2019-05-15 22:26:07 +05:30
Eileen M. Uchitelle
bd0618b1f3
Merge pull request #36237 from eileencodes/fix-erb-in-database-yaml-again
Fix database loading when ERB is single line ternary
2019-05-14 03:29:37 -04:00
George Claghorn
b2b6341374
Add ActionDispatch::SystemTestCase#fill_in_rich_text_area 2019-05-13 12:44:06 -04:00
Xavier Noria
4829214aa2 adds a blank line [ci skip] 2019-05-13 06:00:28 +02:00
Xavier Noria
63f39dd6eb warn about non-eager loaded dirs in zeitwerk:check 2019-05-13 05:49:00 +02:00
Vipul A M
31a3eea5ac Update the sqlite db yaml template to match others and mention proper supported version 2019-05-12 07:08:56 +05:30
eileencodes
5df84533d5 Fix database loading when ERB is single line ternary
*sigh* this seems like the never ending bug. I don't love or even like
this fix but it does _work_.

Rafael suggested using `dummy_key: dummy_value` but unfortunately
that doesn't work. So we're left with checking whethere there might be
ternary type things in the content and then assuming that we want to
replace the line with a key value pair.

Technically fixes https://github.com/rails/rails/issues/36088
2019-05-10 16:28:08 -04:00
Yuji Yaginuma
669b52d296
Merge pull request #36225 from deivid-rodriguez/workaround_sass_rails_requirement
Use a better requirement for sass-rails 6 prereleases
2019-05-09 17:33:55 +09:00
Sharang Dashputre
3d5cf0c595 Fix indentation of the config.eager_load nil warning 2019-05-09 13:17:04 +05:30
David Rodríguez
786bdc4c11
Use a better requirement for sass-rails 6 prereleases
This is the behavior I naively expect for the operator when used with a
single digit, but it's definitely an edge case for it, and it doesn't
seem to work as expected for including prereleases.

Using >= works fine and make the intention more clear anyways.
2019-05-09 09:40:30 +02:00
Dan
2c071e0246
minor grammar fix
"setup" is a noun, "set up" is the verb phrase
2019-05-08 14:10:47 -07:00
Abhay Nikam
dd643f4893 Fix indentation for config.eager_load nil warning message 2019-05-08 20:57:16 +05:30
yuuji.yaginuma
85a8bc644b Make generated test work even when using virtual attributes
The virtual attributes(`attachment` and `rich_text`) can't set value
with `fill_in`. So avoid using it. Once #35885 is merged, will be
modified to use it.

Also, add checking attachment attached or not for avoiding
`DelegationError` when attachment didn't attach.
2019-05-05 09:55:37 +09:00
Ryuta Kamizono
c1ff1392db Fix rubocop offences 2019-04-30 18:32:41 +09:00
Xavier Noria
b6e17b6a4b new config to opt-out from adding app directories to $LOAD_PATH 2019-04-28 13:48:26 +02:00
Prathamesh Sonpatki
fa0ce5c790
Bump bootsnap to a version with disables iseq_cache for Ruby 2.5
- Refs https://github.com/Shopify/bootsnap/pull/257
2019-04-26 12:55:28 +05:30
Rafael Mendonça França
9834be6565
Start Rails 6.1 development 2019-04-24 15:57:14 -04:00
Rafael França
5566b4a636
Merge pull request #36067 from st0012/update-generator-for-api-app
Remove action_controller.perform_caching from api app's configs
2019-04-23 14:37:46 -04:00
Rafael França
d33f5e55f1
Merge pull request #35852 from larouxn/resurrection
Resurrect external JS/CS generation
2019-04-23 14:21:30 -04:00
st0012
d63f9383a6 Remove action_controller.perform_caching from api app's configs
As suggested in https://github.com/rails/rails/issues/35602#issuecomment-485833483, because we don't provide view caching and doesn't include `ActionController::Caching` for api apps, we should also avoid generating

```ruby
config.action_controller.perform_caching = true
```

for those api apps. So it won't confuse people.

**But because `perform_caching` will be `true` if not set, the behavior of the app would still be the same without these configs.**
2019-04-24 02:08:13 +08:00
Xavier Noria
afc17e5ea2 Implements the task zeitwerk:check
[Matilda Smeds & Xavier Noria]
2019-04-23 03:17:34 +02:00
Guillermo Iguaran
2e4c65e3af Allow sass-rails greater than 5.x in new apps 2019-04-22 14:35:04 -05:00
Jeremy Weathers
b08daf48da [#35782] Allow loading seeds without ActiveJob (~> 5.2.3) 2019-04-19 10:57:42 -05:00
Prathamesh Sonpatki
8b4d344815
Add null: false constraint by default for belongs_to associations
- Also deprecate passing {required} to the model generator.
- Also made sure the global config `belongs_to_required_by_default` is
  applied correctly to the model generator for `null: false` option.
2019-04-19 20:08:29 +05:30
Kasper Timm Hansen
10da0a2751
Merge pull request #34788 from gsamokovarov/actionable-errors
Introduce Actionable Errors
2019-04-19 15:38:57 +02:00
akinomaeni
1cd88288d5 Help command for visible commands should be hidden
```
$ rails --help > tmp/before
$ bundle update rails
...
$ rails --help > tmp/after
$ diff -u tmp/before tmp/after
--- tmp/before	2019-04-19 00:12:08.000000000 -0700
+++ tmp/after	2019-04-19 00:14:55.000000000 -0700
@@ -52,7 +52,6 @@
   db:version
   destroy
   dev:cache
-  dev:help
   encrypted:edit
   encrypted:show
   initializers
```
2019-04-19 00:33:12 -07:00
Genadi Samokovarov
54df392bc5 Manage ActionDispatch::ActionableExceptions from the default middleware stack 2019-04-19 14:15:22 +09:00
David Stosik
6f73a31c0c
Factorize bin/update in bin/setup, and make bin/setup idempotent
`bin/setup` and `bin/update` are currently almost the same file. The
only thing that keeps them apart is that one is running `bin/rails
db:setup` and the other `bin/rails db:migrate`.

I'm suggesting here that they should be a unique script, which needs to
be idempotent.

- New to a project, need to get started? `bin/setup`
- Need to install new dependencies that were added recently? `bin/setup`.

Before deprecating `bin/update`, I'm suggesting we just have it call
`bin/setup`.
2019-04-17 00:45:17 +02:00
Lachlan Sylvester
4f2ac80d4c
Add collection cache versioning
Cache versioning enables the same cache key to be reused when the object
being cached changes by moving the volatile part of the cache key out of
the cache key and into a version that is embedded in the cache entry.

This is already occurring when the object being cached is an
`ActiveRecord::Base`, but when caching an `ActiveRecord::Relation`
we are currently still putting the volatile information (max updated at
and count) as part of the cache key.

This PR moves the volatile part of the relations `cache_key` into the
`cache_version` to support recycling cache keys for
`ActiveRecord::Relation`s.
2019-04-16 22:54:15 +02:00
Thierry Joyal
963d11a000 [Rails::MailersController] Do not leak I18n global setting changes 2019-04-16 18:54:51 +00:00
Rafael França
81c8f18d84
Merge pull request #35906 from yoones/notes-tags-registration
Notes tags registration
2019-04-15 17:46:07 -04:00
Xavier Noria
65344f254c generate config.cache_classes = false if Spring 2019-04-14 23:09:02 +02:00
Xavier Noria
3e66ba91d5 deprecates autoloading constants during initialization [closes #35745]
See rationale in the warning message included in the patch.
2019-04-14 12:09:09 +02:00
yuuji.yaginuma
319c295bba Do not treat environment_desc as commands
For avoid to show `environment_desc` in help.
2019-04-13 08:41:37 +09:00
Younes SERRAJ
6463cc0573 Adds register_tags 2019-04-12 08:55:42 +02:00
Ryuta Kamizono
43288a053f
Merge pull request #35916 from soartec-lab/delete_not_use_method
Delete not user method for plugin_generator
2019-04-11 02:55:20 +09:00
soartec-lab
831fa3dacb Delete not user method for plugin_generator 2019-04-09 22:36:25 +09:00
BatedUrGonnaDie
75811c37a9 Only override async adapter when seeding 2019-04-09 00:35:16 -07:00
Xavier Noria
57c7cbb162 depend on Zeitwerk 2 2019-04-07 13:05:26 +02:00
Nicholas La Roux
cf5049f88b
Burn unnecessary files 🔥 2019-04-05 16:09:23 +09:00
Nicholas La Roux
b46700da60
Style fixes 2019-04-05 16:09:23 +09:00
Nicholas La Roux
5d944d679b
Resurrect generator templates 2019-04-05 16:09:23 +09:00
Nicholas La Roux
d442d97bfa
Resurrect js/js engine options and generators 2019-04-05 16:09:22 +09:00
Ryuta Kamizono
0908184e4c Use execute_batch2 rather than execute_batch to fix performance regression for fixture loading
d8d6bd5 makes fixture loading to bulk statements by using
`execute_batch` for sqlite3 adapter. But `execute_batch` is slower and
it caused the performance regression for fixture loading.

In sqlite3 1.4.0, it have new batch method `execute_batch2`. I've
confirmed `execute_batch2` is extremely faster than `execute_batch`.
So I think it is worth to upgrade sqlite3 to 1.4.0 to use that method.

Before:

```
% ARCONN=sqlite3 bundle exec ruby -w -Itest test/cases/associations/eager_test.rb -n test_eager_loading_too_may_ids
Using sqlite3
Run options: -n test_eager_loading_too_may_ids --seed 35790

# Running:

.

Finished in 202.437406s, 0.0049 runs/s, 0.0049 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
ARCONN=sqlite3 bundle exec ruby -w -Itest  -n test_eager_loading_too_may_ids  142.57s user 60.83s system 98% cpu 3:27.08 total
```

After:

```
% ARCONN=sqlite3 bundle exec ruby -w -Itest test/cases/associations/eager_test.rb -n test_eager_loading_too_may_ids
Using sqlite3
Run options: -n test_eager_loading_too_may_ids --seed 16649

# Running:

.

Finished in 8.471032s, 0.1180 runs/s, 0.1180 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
ARCONN=sqlite3 bundle exec ruby -w -Itest  -n test_eager_loading_too_may_ids  10.71s user 1.36s system 95% cpu 12.672 total
```
2019-04-04 03:27:46 +09:00
Ryuta Kamizono
fe006083ea Don't normalize original_app_name
`original_app_name` is used to show error message if giving app name is
invalid, it should be shown raw app name.
2019-04-03 17:56:04 +09:00
Rafael França
6c6c579a9b
Merge pull request #35805 from excid3/attachments-field-generators
Add attachment and attachments field generators
2019-04-02 19:13:25 -04:00
yuuji.yaginuma
29b16d3ff8 Rename connection option to database in dbconsole command
We introduced `connection` option for specifying spec with 1acd9a6464668d4d54ab30d016829f60b70dbbeb.
But now we are using the `database` to specify the same value in other commands.

* 0a0f115031/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb (L11)
* 0a0f115031/activerecord/lib/rails/generators/active_record/model/model_generator.rb (L17)

The options provided to the users should be uniform. Since the term
"database" is used in rake task etc, So I want to be able to use it in
`dbconsole` command.

Also I deprecated the `connection` option because I think that it
would be confusing if there are multiple options to specify a same value.
2019-04-02 13:15:55 +09:00
Ryuta Kamizono
e4e1218583
Merge pull request #35820 from sharang-d/url-to-URL-except-actionpack
url -> URL where apt except inside actionpack/
2019-04-02 03:26:31 +09:00
Sharang Dashputre
771973c13d url -> URL where apt except inside actionpack/ 2019-04-01 22:56:35 +05:30
Orhan Toy
db4c6f5ecb Include final newline in generated .ruby-version 2019-04-01 18:39:15 +02:00
Chris Oliver
ecdcf06cb2 Add attachment and attachments field generators 2019-03-30 12:15:17 -05:00
Xavier Noria
a3e061def1 optimizes eager loading in :zeitwerk mode
During initialization, the eager load paths of engines are unshifted
into AS::Dependencies.autoload_paths. After that, the collection is
frozen. (See the initializers in railties/lib/rails/engine.rb.)

Hence, there is no eager load path that is not an autoload path too, and
so the array difference in the deleted code is always an empty array.

Just do nothing.
2019-03-30 13:01:42 +01:00
Xavier Noria
278f0dfeac fixes eager loading edge case in :zeitwerk mode 2019-03-30 09:33:48 +01:00
Chris Oliver
19a29c6556 Add rich_text field to model generators 2019-03-28 23:58:33 -05:00
Xavier Noria
379d7e8bfa bumps Zeitwerk and Bootsnap 2019-03-26 20:30:18 +01:00
Guillermo Iguaran
df51b75f12
Merge pull request #35732 from rails/webdrivers
Replace chromedriver-helper with webdrivers
2019-03-24 16:33:24 -05:00
Guillermo Iguaran
b4ca05ea43
Merge pull request #35723 from sikachu/disable-sandbox-flag
Add config.disable_sandbox option to Rails console
2019-03-24 16:22:21 -05:00
Guillermo Iguaran
895edbcf40 Use webdrivers instead of chromedriver-helper in new apps 2019-03-24 16:08:09 -05:00
Yuji Yaginuma
122853dc54
Merge pull request #35718 from y-yagi/add_secret_key_base_when_creating_new_credentials
Add `secret_key_base` when creating new credential file
2019-03-24 09:44:13 +09:00
Prem Sichanugrist
b27105252b Add config.disable_sandbox option to Rails console
A long-running `rails console --sandbox` could cause a database server
to become out-of-memory as it's holding on to changes that happen on the
database.

Given that it's common for Ruby on Rails application with huge
traffic to have separate write database and read database, we should
allow the developers to disable this sandbox option to prevent someone
from accidentally causing the Denial-of-Service on their server.
2019-03-23 19:31:03 +09:00
John Hawthorn
d0334b8f01 Update comment for how secret key is calculated
This updates the comment to reflect how the secret key is generated
since 4c743587ad6a31908503ab317e37d70361d49e66

Fixes #35717
2019-03-22 17:59:41 -07:00
yuuji.yaginuma
0e9e59953f Add secret_key_base when creating new credential file
Since `secret_key_base` is expected to be included in credential file,
`secret_key_base` should be included even if re-create the file. This is
the same behavior as creating a new app.
When env is specified, it may be unnecessary, so I added it only when not
specifying env.
2019-03-23 09:07:57 +09:00
John Hawthorn
663548845b Use symbol for mail preview format, not string 2019-03-18 16:06:31 -07:00
yuuji.yaginuma
6f94260ac6 Add -e/--environment option to rails initializers
This allows specifying the environment as would any other rails commands.
2019-03-16 10:02:06 +09:00
yuuji.yaginuma
c801b232bc Properly expand the environment's name in all commands
Since 3777701f1380f3814bd5313b225586dec64d4104, the environment's name is
automatically expanded in console and dbconsole commands.
In order to match the behavior between the commands, fixes it to have the
same behavior of all the commands.

This behavior is defined in `EnvironmentArgument`. Since
`EnvironmentArgument` also defines the environment option, it is reused.

However, since desc was not content that can be used in all comments,
fixed desc to be defined for each command.
2019-03-15 07:43:10 +09:00
yuuji.yaginuma
0187053109 Make application work without tmp directory
The tmp directory is added to version control in the newly created
application. This was added in Rails 5.0.0(f06ce4c12a).

However, applications created before that are not guaranteed to have the
tmp directory. If the tmp directory does not exist, writing to the key file
raise error.

This is a bit incompatible. So I fixed that create the directory before
writing a key.
2019-03-14 16:14:15 +09:00
eileencodes
a2bd669ed2 v6.0.0.beta3 release
-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEEvJkGf0BARV+D0L2ulxXUSC76N8FAlyJN4cACgkQulxXUSC7
 6N9ZXAf/Wx7edIct8kZzcC6irlROx4DzpNbrrH792sO1OAcnoFDE7DPkokllTEP/
 4kzC42lca/XG27MCl7E0dtVD8hIyAl89nxid6cwKFVZVTPIRVc1wjXkoiWy/cvd7
 6+9IjxhlgrzxGnw3aWZJG7H3iqz69yr55aoSDU/TbMqq5kQrqNF95vr2nc8LEUco
 SLQj0pO/tfJdHquSeX0JiXn3VSEHT+5TdLGQ3J/w0wFU6mkecH4MJMJvMwLFx/v4
 llnvF6HyfSLASWbrpdD3h6MQHpImDoee5vILXAHzPdSaEVcVa1cDFtMcPMYiu8Dw
 AGdCAaHQhZFFGoYK472+o6pur0dxEA==
 =5dET
 -----END PGP SIGNATURE-----

Merge tag 'v6.0.0.beta3'

v6.0.0.beta3 release
2019-03-13 13:11:10 -04:00
Akira Matsuda
9f02a8f89b Indentation >> 2019-03-13 19:34:50 +09:00
yuuji.yaginuma
12ddee0ce8 Fix rubocop violations 2019-03-13 17:51:46 +09:00
Sharang Dashputre
ad5ca97acc overriden -> overridden [ci skip] 2019-03-12 04:08:51 +05:30
Rafael Mendonça França
cfa22f1a4b
Do not generate dummy string when the tag used is not the <%= 2019-03-11 17:49:27 -04:00
Kasper Timm Hansen
3a42c2305e
Merge pull request #34955 from bogdanvlviv/follow-up-33962
Add `config.credentials.content_path` and `config.credentials.key_path` to the guide
2019-03-11 21:08:20 +01:00
Kasper Timm Hansen
f55306f098
[ci skip] Improve encrypted commands USAGE
This streamlines the lovely foundation Bogdan added. Mainly to add
guidance around encryption keys and remove some backticks.

Finally it adds some mention of how to access these files from Ruby
in apps.

[ Kasper Timm Hansen & bogdanvlviv ]
2019-03-11 21:00:00 +01:00
Kasper Timm Hansen
7874257afd
Merge pull request #34965 from bogdanvlviv/improve-rails-encrypted--help
Improve output of `rails encrypted(:edit/:show) --help`
2019-03-11 20:42:36 +01:00
eileencodes
7c87fd5635 Prep release
* Update RAILS_VERSION
* Bundle
* rake update_versions
* rake changelog:header
2019-03-11 11:58:15 -04:00
Ryuta Kamizono
c41269ebc8
Merge pull request #35568 from prathamesh-sonpatki/server_squish
Squish the deprecation messages across the codebase
2019-03-11 23:16:47 +09:00
Prathamesh Sonpatki
538a459a3b
Squish the deprecation messages across the codebase
Sample example ->

Before:

prathamesh@Prathameshs-MacBook-Pro-2 blog *$ rails server thin
DEPRECATION WARNING: Passing the Rack server name as a regular argument is deprecated
and will be removed in the next Rails version. Please, use the -u
option instead.

After:

prathamesh@Prathameshs-MacBook-Pro-2 squish_app *$ rails server thin
DEPRECATION WARNING: Passing the Rack server name as a regular argument is deprecated and will be removed in the next Rails version. Please, use the -u option instead.
2019-03-11 19:22:37 +05:30
Kasper Timm Hansen
2259b486f1
Merge pull request #35569 from prathamesh-sonpatki/env-vars
Mention `environment variable` instead of just `environment`
2019-03-11 14:42:15 +01:00
Prathamesh Sonpatki
4cdc93a1e4
Mention environment variable instead of just environment 2019-03-11 18:54:13 +05:30
Prathamesh Sonpatki
bcc1207a8e
Use the -u switch for the rails server banner
- Because just passing the server argument to this command is
  deprecated in https://github.com/rails/rails/pull/32058
2019-03-11 18:26:49 +05:30
Aaron Patterson
4c743587ad Fix possible dev mode RCE
If the secret_key_base is nil in dev or test generate a key from random
bytes and store it in a tmp file. This prevents the app developers from
having to share / checkin the secret key for dev / test but also
maintains a key between app restarts in dev/test.

[CVE-2019-5420]

Co-Authored-By: eileencodes <eileencodes@gmail.com>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
2019-03-10 21:30:03 -07:00
Kasper Timm Hansen
c87f6841b7
Merge pull request #35121 from utilum/warning_tried_to_create_proc_without_block
Ruby 2.7 warning: creating a Proc without a block
2019-03-10 16:31:15 +01:00
Abhay Nikam
027e492b6f Fix links in gemspec and docs from http to https. 2019-03-09 19:42:35 +05:30
Sharang Dashputre
c2de1f79ab Don't lock the webpacker gem by its patch version 2019-03-09 05:29:36 +05:30
Guillermo Iguaran
cd89082fa9
Merge pull request #35538 from sharang-d/use-latest-webpacker
Use the latest stable release of webpacker
2019-03-08 17:36:54 -05:00
Sharang Dashputre
8eaffa1945 Use the latest stable release of webpacker 2019-03-09 00:14:17 +05:30
Xavier Noria
b686b67191 moves a require to the file that needs it 2019-03-08 09:04:12 -08:00
Jean Boussier
6d624f2de9 Allow autoloader inflectors to be swaped out 2019-03-08 17:31:29 +01:00
Gannon McGibbon
dcbb79d680 Add version awareness to rails db:system:change 2019-03-08 03:14:56 -05:00
eileencodes
37d1429ab1 Load YAML for rake tasks without parsing ERB
This change adds a new method that loads the YAML for the database
config without parsing the ERB. This may seem odd but bear with me:

When we added the ability to have rake tasks for multiple databases we
started looping through the configurations to collect the namespaces so
we could do `rake db:create:my_second_db`. See #32274.

This caused a problem where if you had `Rails.config.max_threads` set in
your database.yml it will blow up because the environment that defines
`max_threads` isn't loaded during `rake -T`. See #35468.

We tried to fix this by adding the ability to just load the YAML and
ignore ERB all together but that caused a bug in GitHub's YAML loading
where if you used multi-line ERB the YAML was invalid. That led us to
reverting some changes in #33748.

After trying to resolve this a bunch of ways `@tenderlove` came up with
replacing the ERB values so that we don't need to load the environment
but we also can load the YAML.

This change adds a DummyCompiler for ERB that will replace all the
values so we can load the database yaml and create the rake tasks.
Nothing else uses this method so it's "safe".

DO NOT use this method in your application.

Fixes #35468
2019-03-06 08:59:27 -05:00
yuuji.yaginuma
970cb21b3a Correctly escape ERB tag
Ref: https://travis-ci.org/rails/rails/jobs/501220262#L1194
2019-03-04 08:17:16 +09:00
Guillermo Iguaran
61b126ff6c
Add an example about how to load images under app/javascript/images
Similarly to https://github.com/rails/webpacker/pull/1976
2019-03-03 16:19:13 -05:00
Rafael Mendonça França
5e6e505083
Preparing for 6.0.0.beta2 release 2019-02-25 17:45:04 -05:00
Rafael Mendonça França
4e105988bd
Depend on bootsnap 1.4.1
This is needed to fix #35278.
2019-02-25 14:21:44 -05:00
Xavier Noria
b7fe3bddef simplifies Rails.autoloaders.logger=
Possible thanks to Zeitwerk 1.3.0.
2019-02-21 14:51:28 -08:00
Xavier Noria
39aaa0264a Define Rails.autoloaders.logger= 2019-02-21 01:57:21 -08:00
Xavier Noria
2420c44d4b Explains a detail re eager loading [ci skip] 2019-02-20 14:24:26 -08:00
Yoshiyuki Hirano
ed3f315907 Auto correct rubocop offenses
Offenses:

railties/lib/rails/autoloaders.rb:1:1: C: [Corrected] Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
module Rails
^
actionmailer/test/base_test.rb:917:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
actionmailer/test/base_test.rb:917:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
actionmailer/test/base_test.rb:917:5: C: [Corrected] Style/RedundantBegin: Redundant begin block detected.
    begin
    ^^^^^
actionmailer/test/base_test.rb:918:3: C: [Corrected] Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.
      events = []
  ^^^^
actionmailer/test/base_test.rb:930:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body end.
actionmailer/test/base_test.rb:930:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
2019-02-17 17:12:22 +09:00
Xavier Noria
870377915a Replace autoloader accessors with Rails.autoloaders.{main,once}
Rails.autoloader and Rails.once_autoloader was just tentative API good
enough for a first patch. Rails.autoloader is singular and does not
convey in its name that there is another autoloader. That might be
confusing, for example if you set a logger and miss traces. On the other
hand, the name `once_autoloader` is very close to being horrible.

Rails.autoloaders.main and Rails.autoloaders.once read better for my
taste, and have a nice symmetry. Also, both "main" and "once" are four
letters long, short and same length.

They are tagged as "rails.main" and "rails.once", respectively.

References #35235.
2019-02-14 22:34:16 -08:00
Rafael Mendonça França
79b8b62621
Merge pull request #35249 from Edouard-chin/ec-config-for-hash-in-arrau
Fix the `config_for` to always return a NonSymbolAccessDeprecatedHash:
2019-02-14 21:21:47 -05:00
Edouard CHIN
4f7231da70 Fix the config_for to always return a NonSymbolAccessDeprecatedHash:
- If you have hashes inside array, the hashes were getting initialized
  as regular HWIA wereas we want them to be
  NonSymbolAccessDeprecatedHash in order to trigger a deprecation
  warning when keys are accessed with string.

  This patch fixes that by overwriting the `[]=` to to the same
  as what HWIA does (with the difference that we don't call
  `convert_key` to not trigger a deprecation when setting value).

  I also took the liberty to extract `hash.nested_under_indifferent_access`,
  into a separate method to allow subclasses to return whatever
  they want.
  Inheriting HWIA is not common, but I think it's useful for cases
  like this one where we want to preprocess reading and writing values
  in the hash (for deprecation purposes or other reasons).
2019-02-14 14:11:05 +01:00
Xavier Noria
c36b6c8d38 Let Zeitwerk be a dependency of Active Support
Zeitwerk is a strong dependency, planned to replace AS::Dependencies. A
line in the generated Gemfile does not convey this as much.
2019-02-13 12:27:53 -08:00
utilum
87a5379b42 Ruby 2.7 warning: creating a Proc without a block
As of [Revision 66772](
https://bugs.ruby-lang.org/projects/ruby-trunk/repository/trunk/revisions/66772)
 `Proc.new` without giving a block emits `warning: tried to create Proc object without a block`.

This commit fixes cases where Rails test suit tickles this warning.

See CI logs:
https://travis-ci.org/rails/rails/jobs/487205819#L1161-L1190
https://travis-ci.org/rails/rails/jobs/487205821#L1154-1159
https://travis-ci.org/rails/rails/jobs/487205821#L1160-L1169
https://travis-ci.org/rails/rails/jobs/487205821#L1189
https://travis-ci.org/rails/rails/jobs/487254404#L1307-L1416
https://travis-ci.org/rails/rails/jobs/487254405#L1174-L1191
2019-02-13 02:11:21 +01:00
Xavier Noria
821d6c694c Zeitwerk integration 2019-02-12 02:28:04 -08:00
Gannon McGibbon
f9e6819851
Merge pull request #35198 from paracycle/uk-change-config-for-behaviour
Allow deprecated non-symbol access to nested `config_for` hashes
2019-02-11 15:05:55 -05:00
Ufuk Kayserilioglu
325e917f5a Allow deprecated non-symbol access to nested config_for hashes
A change to `Rails::Application.config_for` in
https://github.com/rails/rails/pull/33815 and
https://github.com/rails/rails/pull/33882 has altered the behaviour of
the returned object in a breaking manner. Before that change, nested
hashes returned from `config_for` could be accessed using non-symbol keys.
After the change, all keys are recursively symbolized so non-symbol access
fails to read the expected values.

This is a breaking change for any app that might be relying on the
nested hashes returned from `config_for` calls, and thus should be
deprecated before being removed from the codebase.

This commit introduces a temporary `NonSymbolAccessDeprecatedHash` class
that recursively wraps any nested hashes inside the `OrderedOptions`
object returned from `config_for` and issues a deprecation notice when a
non-symbol based access is performed.

This way, apps that are still relying on the ability to access these
nested hashes using non-symbol keys will be able to observe the
deprecation notices and have time to implement changes before non-symbol
access is removed for good.

A CHANGELOG entry is also added to note that non-symbol access to nested
`config_for` hashes is deprecated.
2019-02-11 14:12:10 -05:00
alkesh26
3bd036637a Optimized namespaces_to_paths method. 2019-02-11 23:25:11 +05:30
John Hawthorn
3302d2c2e6 Rename database_operations config to *_context 2019-02-07 15:41:43 -08:00
Aaron Patterson
7d0ce785d4
Remove finalizer and configuration 2019-02-06 16:57:04 -08:00
Sergey Ponomarev
d9601fd622
Set sqlite3 gem version explicitly in generated Gemfile 2019-02-05 11:56:32 -05:00
Peter Baker
43b06efe78 Update instructions in generated Postgresql database.yml. 2019-02-02 18:42:19 +01:00
Eileen M. Uchitelle
79bc9e81c3
Merge pull request #35126 from alkesh26/railities-typo-fix
Railties typo fixes.
2019-02-01 08:40:48 -05:00
alkesh26
79c3cef444 Railities typo fixes. 2019-02-01 16:42:40 +05:30
Ryuta Kamizono
7ebfb319ff Enable Lint/ErbNewArguments cop to avoid the deprecated arguments warning
Related 5754a29a974d31cab2b4392716b9825a3d910a69.

And follows Ruby standard library style https://github.com/ruby/ruby/commit/3406c5d.
2019-02-01 14:20:11 +09:00
Yuji Yaginuma
6729cef751
Merge pull request #34980 from y-yagi/fixes_34979
Don't add `RAILS_ENV` in generate action
2019-01-31 07:19:22 +09:00
Eileen Uchitelle
0abcec416b Adds basic automatic database switching to Rails
The following PR adds behavior to Rails to allow an application to
automatically switch it's connection from the primary to the replica.

A request will be sent to the replica if:

* The request is a read request (`GET` or `HEAD`)
* AND It's been 2 seconds since the last write to the database (because
we don't want to send a user to a replica if the write hasn't made it
to the replica yet)

A request will be sent to the primary if:

* It's not a GET/HEAD request (ie is a POST, PATCH, etc)
* Has been less than 2 seconds since the last write to the database

The implementation that decides when to switch reads (the 2 seconds) is
"safe" to use in production but not recommended without adequate testing
with your infrastructure. At GitHub in addition to the a 5 second delay
we have a curcuit breaker that checks the replication delay
and will send the query to a replica before the 5 seconds has passed.
This is specific to our application and therefore not something Rails
should be doing for you. You'll need to test and implement more robust
handling of when to switch based on your infrastructure. The auto
switcher in Rails is meant to be a basic implementation / API that acts
as a guide for how to implement autoswitching.

The impementation here is meant to be strict enough that you know how to
implement your own resolver and operations classes but flexible enough
that we're not telling you how to do it.

The middleware is not included automatically and can be installed in
your application with the classes you want to use for the resolver and
operations passed in. If you don't pass any classes into the middleware
the Rails default Resolver and Session classes will be used.

The Resolver decides what parameters define when to
switch, Operations sets timestamps for the Resolver to read from. For
example you may want to use cookies instead of a session so you'd
implement a Resolver::Cookies class and pass that into the middleware
via configuration options.

```
config.active_record.database_selector = { delay: 2.seconds }
config.active_record.database_resolver = MyResolver
config.active_record.database_operations = MyResolver::MyCookies
```

Your classes can inherit from the existing classes and reimplment the
methods (or implement more methods) that you need to do the switching.
You only need to implement methods that you want to change. For example
if you wanted to set the session token for the last read from a replica
you would reimplement the `read_from_replica` method in your resolver
class and implement a method that updates a new timestamp in your
operations class.
2019-01-30 13:37:25 -05:00
yuuji.yaginuma
1d26c86b86 Convert path to string before call length
Because eager load paths support to using `Pathname`, and `Pathname`
doesn't have `length` method.
Ref: https://travis-ci.org/rails/rails/jobs/485088071#L5140-L5143

Follow up aadeed1518b9092ea21adf49c728172368129f0e.
2019-01-28 08:00:11 +09:00
Xavier Noria
aadeed1518 Simplify path prefix extraction 2019-01-27 18:41:38 +01:00
Vipul A M
662ea46237
Fix typo: overriden -> overridden [ci skip] (#35060) 2019-01-26 15:43:30 +05:30
Kasper Timm Hansen
5f7d5995a6
Merge pull request #34789 from christos/fix-editing-new-environment-credentials
Don't load app environment when editing credentials
2019-01-25 00:07:33 +01:00
Gannon McGibbon
a670654882 Fix deeply nested namespace command printing 2019-01-24 12:28:43 -05:00
Rafael França
d1456e3ad5
Merge pull request #34993 from schuetzm/allow-subdomains-of-localhost
Subdomains of localhost are safe against DNS rebinding
2019-01-23 13:15:15 -05:00
Marc Schütz
4dfb1a3961 Subdomains of localhost are safe against DNS rebinding 2019-01-23 13:30:35 +01:00
Eileen M. Uchitelle
e26f0658da
Merge pull request #34997 from alkesh26/typo-fix-webserver
Replaced webserver with web server
2019-01-22 11:13:37 -05:00
alkesh26
97909ddcf2 Changed webserver to web server. 2019-01-22 21:11:03 +05:30
bogdanvlviv
7ec67c1d31
Add Channel tests to rails stats
Rails generates `test/channels`(#34933) and
even allows `rails test:channels` (#34947).
`rails stats` has been providing info about `app/channels`,
it makes sense to add `test/channels` as well.

(I've changed test because we generate `test/channels` with some code)
2019-01-21 10:45:08 +00:00
Dan McGregor
cc8c72a4bd Report statistics from ActionMailbox 2019-01-20 11:15:20 +00:00
yuuji.yaginuma
82e9866703 Don't add RAILS_ENV in generate action
In the case of generator, `RAILS_ENV` is interpreted as an argument as it
is. Avoid this because it will result unintended by the user.

Fixes #34979.
2019-01-19 16:39:18 +09:00
Rafael Mendonça França
5a0230c67f
Preparing for 6.0.0.beta1 release 2019-01-18 15:42:12 -05:00
yuuji.yaginuma
eb63faaa1a Revert "Remove deprecated server argument from the rails server command"
This reverts commit fa791fb8e2a718b5d0430c7ca5a454678dfc192d.

Reason: `server` argument was deprecated in Rails 6.0. Ref: #32058.
2019-01-18 09:58:55 +09:00
Rafael Mendonça França
3219e4aef1
Use released webpacker 2019-01-17 17:21:09 -05:00
Rafael Mendonça França
4d51efe24e
Remove deprecated after_bundle helper inside plugins templates 2019-01-17 16:08:35 -05:00
Rafael Mendonça França
fa791fb8e2
Remove deprecated server argument from the rails server command 2019-01-17 16:08:35 -05:00
Rafael Mendonça França
553b86fc75
Remove deprecated support to old config.ru that use the application class as argument of run 2019-01-17 16:08:34 -05:00
Rafael Mendonça França
e20589c9be
Remove deprecated environment argument from the rails commands 2019-01-17 16:08:34 -05:00
Rafael Mendonça França
9d39f81d51
Remove deprecated capify! 2019-01-17 16:08:34 -05:00
Rafael Mendonça França
46ac5fe69a
Remove deprecated config.secret_token 2019-01-17 16:08:34 -05:00
Rafael Mendonça França
f59b08119b
Change SQLite3Adapter to always represent boolean values as integers 2019-01-17 16:08:32 -05:00
bogdanvlviv
f133fdd00e
Improve output of rails encrypted(:edit/:show) --help
With these simple examples, It will be easier for users to figure out how to use these commands.

Related to 68479d09ba6bbd583055672eb70518c1586ae534
2019-01-17 19:02:38 +00:00
Rafael França
2dee59fed1
Merge pull request #34953 from gmcgibbon/seed_with_inline_jobs
Seed database with inline ActiveJob job adapter
2019-01-17 11:06:41 -05:00
Gannon McGibbon
66cc0e768f Seed database with inline ActiveJob job adapter 2019-01-17 01:08:15 -05:00
bogdanvlviv
4aa9935c2f
Add config.credentials.content_path and config.credentials.key_path to the guide
- Fix some typos

Follow up #33962
2019-01-17 01:45:54 +00:00
George Claghorn
9e34df0003
Merge pull request #33419 from bogdanvlviv/update-active_storage
`rake app:update` should update active_storage
2019-01-16 17:04:47 -06:00
Kasper Timm Hansen
36468bd2dc
Add a space in framework names. Matches Active Record in generated Gemfile. 2019-01-16 23:34:53 +01:00
Javan Makhmali
385d31d209 Minimize boilerplate setup code for JavaScript libraries 2019-01-16 16:15:43 -05:00
Kasper Timm Hansen
cb3f78aa7c
Merge branch 'master' into db_system_change_command 2019-01-16 22:00:51 +01:00
bogdanvlviv
d7097cf5e0
Add rails test:channels.
Add this rake task to test channels only.
We've added `rails test:mailboxes` recently in the same way #34828.
2019-01-16 16:34:34 +00:00
bogdanvlviv
a43052cbbc
Remove frozen_string_literal from Action Cable's template files
Related to 837f602fa1b3281113dac965a8ef96de3cac8b02

Fix the testing guide.
2019-01-16 15:14:35 +00:00
bogdanvlviv
2bad3f46cd
Add foreign key to active_storage_attachments for blob_id via new migration
We need this in order to be able to add this migration for users that
use ActiveStorage during update their apps from Rails 5.2 to Rails 6.0.

Related to #33405

`rake app:update` should update active_storage

`rake app:update` should execute `rake active_storage:update`
if it is used in the app that is being updated.
It will add new active_storage's migrations to users' apps during update Rails.

Context https://github.com/rails/rails/pull/33405#discussion_r204239399

Also, see a related discussion in the Campfire:
https://3.basecamp.com/3076981/buckets/24956/chats/12416418@1236713081
2019-01-16 13:13:23 +00:00
Kasper Timm Hansen
54d4a518d9
Merge pull request #33962 from kaspth/restructure-environment-credentials
Restructure credentials after environment overrides.
2019-01-14 21:03:53 +01:00
Kasper Timm Hansen
37c948ce67
Restructure credentials after environment overrides.
Follow up to: e0d3313

- Revert renames from `encrypted` and `encrypted_file` back to `credentials`.
  They might be using our Encrypted* generators but from that level of abstraction
  they're still about credentials.

- Same vein: extract a `credentials` method for the `encrypted` local variable. But
  don't call it `encrypted` just because it uses that under the hood. It's about
  capturing the credentials. It's also useful in `change_credentials_in_system_editor`.

- Remove lots of needless argument passing. We've abstracted content_path and key_path
  into methods for a reason, so they should be used. Also spares a conspicuous rename
  of content_path into file_path in other methods.

- Reorders private methods so they're grouped into: command building blocks, option
  parsers, and the generators.

- Extracts commonality in the credentials application tests. A tad unsure about this.
  But I do like that we go with key, content thus matching the command and remove the
  yield which isn't really needed.

- Moves test/credentials_test.rb to beneath the test/application directory. It's a
  Rails application test, so it should be in there.

- Uses `root.join` — a neat trick gleaned from the tests! — and composes the configuration
  private methods such that the building block is below the callers.
2019-01-14 20:13:00 +01:00
Vladimir Dementyev
fc95836f87
Add connection_test to app generator 2019-01-13 22:56:12 -05:00
Gannon McGibbon
eedd9548ad
Merge pull request #34913 from bogdanvlviv/docs_config_action_mailer_delivery_job
Add info about `config.action_mailer.delivery_job` to the guide [ci skip]
2019-01-11 13:54:37 -05:00
bogdanvlviv
3f6449f4bf
Add info about config.action_mailer.delivery_job to the guide [ci skip]
Also, add mention to `new_framework_defaults_6_0.rb` that
`ActionMailer::Parameterized::DeliveryJob` is default for parameterized mail
and will be removed.

Related to #34692
2019-01-11 12:48:42 +00:00
okuramasafumi
f897263768 Replace secrets with credentials in comments
In comments in templates for `config/database.yml`, there is a
reference to `secrets.yml` which is now deprecated.
They should be replaced with `credentials.yml` so that everyone
using latest Rails can understand.
2019-01-11 13:35:40 +09:00
Javan Makhmali
86b489e3d6 Move all npm packages to @rails scope
Fixes #33083
2019-01-10 11:01:57 -05:00
Gannon McGibbon
d49899c154 Revise wording on invalid database error messages 2019-01-09 14:23:29 -05:00
Gannon McGibbon
4b1ae57f0f Add rails db:system:change command
Add `rails db:system:change` command for changing databases.

```
bin/rails db:system:change --to=postgresql
   force  config/database.yml
    gsub  Gemfile
```

The change command copies a template `config/database.yml` with
the target database adapter into your app, and replaces your database
gem with the target database gem.
2019-01-09 14:23:25 -05:00
Gannon McGibbon
e3204b9c33 Move application generator naming and database code to concerns 2019-01-09 13:10:40 -05:00
Rafael França
9f1a07af04
Merge pull request #34692 from gmcgibbon/use_mail_delivery_job_in_6.0_defaults
Move MailDeliveryJob default to 6.0 defaults
2019-01-09 13:08:53 -05:00
Ryuta Kamizono
ea65d92f19
Enable Lint/UselessAssignment cop to avoid unused variable warnings (#34904)
* Enable `Lint/UselessAssignment` cop to avoid unused variable warnings

Since we've addressed the warning "assigned but unused variable"
frequently.

370537de05092aeea552146b42042833212a1acc
3040446cece8e7a6d9e29219e636e13f180a1e03
5ed618e192e9788094bd92c51255dda1c4fd0eae
76ebafe594fc23abc3764acc7a3758ca473799e5

And also, I've found the unused args in c1b14ad which raises no warnings
by the cop, it shows the value of the cop.
2019-01-09 18:09:01 +09:00
Marco Costa
d79366b4c9 Preserve Bundle configuration during app generation (#34755)
When generating a new rails application (rails new) using a custom template that
includes gems from an authenticated source, the user has to provide credentials to
bundler.

One way to do this is by exporting environment variables, for example:

export BUNDLE_GITHUB__COM=user:pass: provides credentials for bundler to fetch
gems from github.com.

The problem this PR addresses is that we are currently scrubs all /BUNDLE_.*/
environment variables by wrapping our system calls in Bundler.with_clean_env.

We do this because we don't want our commands executed against the generated project
to use the generator's bundler environment (e.g. our gems): the generated project should
use it's own configuration.

The problem with Bundler.with_clean_env is that, on top of restoring environment
variables to their original state, it also scrubs any /BUNDLE_.*/ variables, which is harmful for authenticated gem sources.

This PR replaces Bundler.with_clean_env with Bundler.with_original_env, which only
restores environment variables to their initial state, without additional scrubbing.
2019-01-09 07:52:06 +09:00
Kasper Timm Hansen
80c7038bbc
Revert "Merge pull request #34387 from yhirano55/rails_info_properties_json"
We had a discussion on the Core team and we don't want to expose this information
as a JSON endpoint and not by default.

It doesn't make sense to expose this JSON locally and this controller is only
accessible in dev, so the proposed access from a production app seems off.

This reverts commit 8eaffe7e89719ac62ff29c2e4208cfbeb1cd1c38, reversing
changes made to 133e0ba33db5887b047c9ac8233e5b414657bca5.
2019-01-08 22:21:20 +01:00
Kasper Timm Hansen
647d7e6167
Revert "Revert "Merge pull request #34387 from yhirano55/rails_info_properties_json""
I reverted the wrong commit. Damn it.

This reverts commit f66a977fc7ae30d2a07124ad91924c4ee638a703.
2019-01-08 22:19:22 +01:00
Kasper Timm Hansen
f66a977fc7
Revert "Merge pull request #34387 from yhirano55/rails_info_properties_json"
We had a discussion on the Core team and we don't want to expose this information
as a JSON endpoint and not by default.

It doesn't make sense to expose this JSON locally and this controller is only
accessible in dev, so the proposed access from a production app seems off.

This reverts commit 8eaffe7e89719ac62ff29c2e4208cfbeb1cd1c38, reversing
changes made to b6e4305c3bca4c673996d0af9db0f4cfbf50215e.
2019-01-08 22:16:58 +01:00
Rafael França
1858614219
Merge pull request #34132 from ConfusedVorlon/enable_fragment_cache_log_in_dev
enable_fragment_cache_logging in dev by default
2019-01-08 14:15:16 -05:00
Gannon McGibbon
e5f2d2906a Move MailDeliveryJob default to 6.0 defaults 2019-01-07 17:38:21 -05:00
bogdanvlviv
814b3cbdea
Revert "Remove node_modules path from assets load paths since we use webpack by default"
This reverts commit 129f8ac6ffcafb2e6e13c9ef13dda4cc47f5af0d.

See 02d2958b6c (commitcomment-31849196)
2019-01-06 01:07:36 +02:00
George Claghorn
f99b3c5f97
Merge pull request #34865 from cbandy/node_rails_env
Respect Rails.env when running `rails yarn:install`
2019-01-05 12:04:56 -05:00
bogdanvlviv
6b8048173d
Add --skip-action-text option to rails new
Since PR#34816 was merged in c6ef670aee186a2880b7be59c4c6892b5c983e58,
we should add this option for flexibility, and consistency.
2019-01-05 13:54:35 +02:00
George Claghorn
86517942e4 Generate Action Text's API docs 2019-01-04 23:56:22 -05:00
George Claghorn
0decd2ddc4 Import Action Text 2019-01-04 22:22:49 -05:00
bogdanvlviv
9e1a567b07
Fix new_framework_defaults_6_0.rb file
`Rails.application.config.active_job.return_false_on_aborted_enqueue`
should be commented as well.
2019-01-04 21:58:18 +02:00
Chris Bandy
efa89e5b24 Respect Rails.env when running rails yarn:install
When no environment variables are set the expectation is that we are in
development.
2019-01-04 11:54:47 -06:00
George Claghorn
663f6cc14f
Send Active Storage jobs to dedicated queues by default
Match Action Mailbox, which sets a default queue for each of its two jobs.
2019-01-04 12:43:51 -05:00
Rafael Mendonça França
c6ef670aee
Merge pull request #34816 from bogdanvlviv/add-skip-action-mailbox-option-to-rails-new-cmd
Add `--skip-action-mailbox` option to `rails new`
2019-01-03 16:36:17 -05:00
David Heinemeier Hansson
2584762cd9 Capistrano is no longer a dominant force in the deployment strategy for new apps 2019-01-03 21:27:44 +11:00
George Claghorn
e7bcbf7b29
Add Rake task for testing mailboxes 2018-12-30 16:17:16 -05:00
George Claghorn
7c4457447e Don't load Action Mailbox when Active Storage is skipped 2018-12-29 07:24:56 -05:00
yuuji.yaginuma
fb173b6613 Do not show suggestion message when not exist suggestion
**before**

```
$ ./bin/rails g g
Could not find generator 'g'. Maybe you meant nil?
Run `rails generate --help` for more options.
```

**after**

```
$ ./bin/rails g g
Could not find generator 'g'.
Run `rails generate --help` for more options.
```
2018-12-29 18:57:55 +09:00
bogdanvlviv
a756706846
Add --skip-action-mailbox option to rails new
Related to ddaf06779a
2018-12-28 11:57:02 +02:00
George Claghorn
ddaf06779a Don't load Action Mailbox when Active Record is skipped 2018-12-28 00:48:52 -05:00
George Claghorn
fb69964187 Load Action Mailbox when other components are skipped 2018-12-28 00:31:43 -05:00
George Claghorn
11a8ba1272 Generate Action Mailbox's API docs 2018-12-26 15:53:49 -05:00