Commit Graph

149 Commits

Author SHA1 Message Date
Rafael França
81c8f18d84
Merge pull request #35906 from yoones/notes-tags-registration
Notes tags registration
2019-04-15 17:46:07 -04:00
George Claghorn
f480cfabcd
Remove the Amazon SES ingress
It's unusable and not ready to ship in Rails 6.0. We'll rewrite it for 6.1.
2019-04-14 12:15:54 -04:00
Younes SERRAJ
6463cc0573 Adds register_tags 2019-04-12 08:55:42 +02: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
Sharang Dashputre
51171413bb Reword test names in credentials_test.rb 2019-03-25 12:44:51 +05:30
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
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
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
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
alkesh26
79c3cef444 Railities typo fixes. 2019-02-01 16:42:40 +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
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
fa791fb8e2
Remove deprecated server argument from the rails server command 2019-01-17 16:08:35 -05:00
Rafael Mendonça França
e20589c9be
Remove deprecated environment argument from the rails commands 2019-01-17 16:08:34 -05:00
Kasper Timm Hansen
cb3f78aa7c
Merge branch 'master' into db_system_change_command 2019-01-16 22:00:51 +01:00
George Claghorn
512b5316dd
Add Exim and Qmail support to Action Mailbox 2019-01-12 21:38:26 -05:00
Tomek Maszkowski
b77d2d9a03 Added Postmark ingress support 2019-01-09 18:00:27 -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
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
George Claghorn
a5b2fff64c Import Action Mailbox 2018-12-25 21:32:35 -05:00
Christos Zisopoulos
a39aa99c81 Don't load app environment when editing credentials
This avoids missing key exceptions caused by code that tries to read the credentials before they have been added to the encrypted file, for example when editing the credentials for a new environment.
2018-12-26 00:03:20 +01:00
Ryuta Kamizono
892e38c78e Enable Style/RedundantBegin cop to avoid newly adding redundant begin block
Currently we sometimes find a redundant begin block in code review
(e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205).

I'd like to enable `Style/RedundantBegin` cop to avoid that, since
rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5
(https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with
that situation than before.
2018-12-21 06:12:42 +09:00
yuuji.yaginuma
d0bb649cbf Use string for arguments in server test
When actually execute from the command, the value of ARGV is passed to the
server. So they are String. So let's use the same type in the test.

Also, this removes the following warning in Ruby 2.6.

```
lib/rails/commands/server/server_command.rb:195: warning: deprecated Object#=~ is called on Integer; it always returns nil
```
2018-12-13 16:15:58 +09:00
Wojciech Wnętrzak
e0d3313bac Support environment specific credentials file. (#33521)
For `production` environment look first for `config/credentials/production.yml.enc` file that can be decrypted by
`ENV["RAILS_MASTER_KEY"]` or `config/credentials/production.key` master key.
Edit given environment credentials file by command `rails credentials:edit --environment production`.
Default behavior can be overwritten by setting `config.credentials.content_path` and `config.credentials.key_path`.
2018-09-19 14:02:00 -07:00
Yoshiyuki Kinjo
e2d0b3b375 Fix rails routes -c for controller name consists of multiple word. 2018-08-20 19:17:40 +09:00
Annie-Claude Côté
1ce2f9a55c Move 'rails initializers' command to Rails::Command 2018-08-16 10:46:11 -04:00
Annie-Claude Côté
3e6d03d99e Adds Rails:Command for dev:cache that has the same behaviour as the rake task 2018-08-13 11:27:01 -04:00
Richard Schneeman
91fd679710
Merge pull request #32381 from q-centrix/update-codeclimate-configs
Turn on performance based cops
2018-07-25 16:00:33 -05:00
Matthew Draper
ec387c6dd9
Merge pull request #33229 from albertoalmagro/albertoalmagro/prefer-rails-command-over-bin-rails
Prefer rails command over bin/rails
2018-07-25 04:10:29 +09:30
Dillon Welch
d108288c2f
Turn on performance based cops
Use attr_reader/attr_writer instead of methods

method is 12% slower

Use flat_map over map.flatten(1)

flatten is 66% slower

Use hash[]= instead of hash.merge! with single arguments

merge! is 166% slower

See https://github.com/rails/rails/pull/32337 for more conversation
2018-07-23 15:37:06 -07:00
Markus Doits
889a7ccf08
Allow to explicitly specify whether to output Rails' log to stdout
Before Rails' logger output is mirrored to std out if:

* environment is development and
* the process is not daemonized

It was not possible to change that behaviour, e.g. to disable log output
in that case or enable it in other cases.

Now you can explicitly disable or enable output with the new command
line switch `--log-to-stdout`, regardless of any other circumstances.

```
// enable output in production
rails server -e production --log-to-stdout

// disable output in development
rails server -e development --no-log-to-stdout
```

Enabling output when daemonized still makes no sense (since tty is
detached), but this is ignored for now.

If the command line flag is not specified, old behaviour still
applies, so this change is completely backward compatible.
2018-07-08 17:28:34 +02:00
Kasper Timm Hansen
161ed37d71
Don't show unneeded deprecation warning on server restart.
If booting a server via `rails s -u puma`, we'd convert the
option to a `using` positional.

When using `rails restart` our `restart_command` would the
option converted to the using positional and put that in
the restart command.

Thus we'd show users deprecation warnings for our own code.

Fix that by converting a passed positional to an option instead.

Also: fix initialize method signature. The local_options are an
array, not a hash. But don't even bother assigning defaults as
Thor passes them in.
2018-07-07 10:21:29 +02:00
Alberto Almagro
a7986aeda0 Show rails instead of bin/rails on USAGE instructions
With this commit, rails commands usage instructions display now +rails+
instead of +bin/rails+ within their recommendations.
2018-07-06 22:46:54 +02:00
Alberto Almagro
40b209db53 Recommend use of rails over bin/rails
As discussed in #33203 rails command already looks for, and runs,
bin/rails if it is present.

We were mixing recommendations within guides and USAGE guidelines,
in some files we recommended using rails, in others bin/rails and
in some cases we even had both options mixed together.
2018-07-06 22:46:35 +02:00
Annie-Claude Côté
7e229f7430 Make NotesCommand tests more performant by getting rid of unecessary map
* Get rid of map and replace it with a multiplication of "\n" to generate document with multiple line preceding the annotation
* Reduce number from 1000 to 100 since it achieves the same goal
* Only keep one test for the multiple lines document since it's unecessary to test multiple times
* Update some language in tests names to make it clearer what we are testing
2018-07-05 10:01:46 -04:00
Kasper Timm Hansen
ba38e13c82
Merge pull request #33220 from anniecodes/notes-command
Adds `Rails::Command::NotesCommand` and makes `rake notes` use it under the hood
2018-07-05 10:32:58 +02:00
Annie-Claude Côté
21f7dadbff Adds support to register directories and extensions to NotesCommand
* Require the application and environnement in the notes command in order to load the config files
* Adds tests for both register_directories and register_extensions added to a config file
2018-07-04 14:30:11 -04:00
Annie-Claude Côté
1996fbe2a3 Adds a Rails::Command for Notes
* It is called with `rails notes`
* It defaults to displaying [OPTIMIZE, FIXME and TODO] annotations
* It accepts custom annotations by using `rails notes -a CUSTOM_ANNOTATION OTHER_ANNOTATION`
* It defaults to look for annotations in [app config db lib test] as dictated by SourceAnnotationExtractor
* It supports ENV["SOURCE_ANNOTATION_DIRECTORIES"] but adds a deprecation warning and recommends using register_directories instead
2018-07-04 14:29:35 -04:00
yuuji.yaginuma
df20bf4aa2 Add an assertion that credentials:edit works when RAILS_MASTER_KEY env is specified 2018-06-24 20:57:41 +09:00
Daniel Colson
a1ac18671a Replace assert ! with assert_not
This autocorrects the violations after adding a custom cop in
3305c78dcd.
2018-04-19 08:11:33 -04:00
Yuji Yaginuma
37b373a8d2
Deprecate support for using HOST environment to specify server IP (#32540)
At SuSE, `$HOST` is set by default and is equal to `$HOSTNAME`.
https://www.suse.com/documentation/sled11/book_sle_admin/data/sec_adm_variables.html

Therefore, by default, it binds to hostname instead of `localhost`.
This seems not to be appropriate as default behavior.

In order to avoid the name of the environment variable being used,
I changed the environment variable from `HOST` to `BINDING`.

Fixes #29516.
2018-04-16 14:35:13 +09:00
Genadi Samokovarov
cb25f2c989 Use did_you_mean spell checker for option suggestions
Now that we require Ruby over `2.3`, we can replace the current
suggestion methods we have with tooling from the `did_you_mean` gem.

There is a small user visible change and this is that we now offer a
single suggestion for misspelled options. We are suggesting fixes during
generator invocation and during a mistyped rails server rack handler. In
both cases, if we don't make a proper prediction on the first match, we
won't do so in the second or third one, so in my mind, this is okay.
2018-03-23 11:36:03 +02:00
Kasper Timm Hansen
6629d51a27
Rely on Rails::Command's help output.
We end up with:

```
Usage:
  bin/rails routes [options]

Options:
  -c, [--controller=CONTROLLER]      # Filter by a specific controller, e.g. PostsController or Admin::PostsController.
  -g, [--grep=GREP]                  # Grep routes by a specific pattern.
  -E, [--expanded], [--no-expanded]  # Print routes expanded vertically with parts explained.
```

which does miss the bit about routes being printed in order.

Also:

* Renames options to ease help output readability, then clarifies each option.
* Fixes a bunch of indentation.
2018-03-13 20:56:37 +01:00
Kasper Timm Hansen
ee01c753a3
Merge pull request #32160 from bogdanvlviv/improve-rails-routes-expanded
Draw line of a route name to the end of row console on `rails routes --expanded`
2018-03-11 20:48:50 +01:00
bogdanvlviv
c98050199e
Remove extra arg passed to Rails::Command::RoutesTest#run_routes_command
Related to 6bd33d66dde015a55912af20b469788ba20ddb4e
2018-03-05 15:07:33 +02:00
bogdanvlviv
012a4a3842
Draw line of a route name to the end of row console on rails routes --expanded
In order to get width of console use `IO::console_size`,
See https://ruby-doc.org/stdlib-2.4.1/libdoc/io/console/rdoc/IO.html#method-c-console_size

Related to #32130
2018-03-05 14:56:59 +02:00
yuuji.yaginuma
968c499aca Fix "NameError: undefined local variable or method `host'"
The `host` and `port` can't use this context.
2018-03-05 08:02:04 +09:00
Kasper Timm Hansen
f4ddbff71c
Merge pull request #32058 from gsamokovarov/rails-server-x-option
Introduce explicit rails server handler option
2018-03-04 20:52:48 +01:00