* Remove Copyright years
* Basecamp is now 37signals... again
Co-authored-by: David Heinemeier Hansson <dhh@hey.com>
---------
Co-authored-by: David Heinemeier Hansson <dhh@hey.com>
Generated using the following script and manually reviewed after:
skipkayhil/rails-bin@6898611730
The :messages route was removed because there isn't actually a
MessagesController.
config/boot.rb also has its Gemfile path fixed to point at the root
Gemfile because Action Mailbox does not have a Gemfile.
All the common rails commands and some extended commands use the
infinitive form for the verb in the description. This changes the
remaining tasks to use the infinitive form verb as well, for
consistency.
__Before__
```console
$ bin/rails --help
...
action_mailbox:install Installs Action Mailbox and its dependencies
...
app:template Applies the template supplied by LOCATION=(/path/to/template) or URL
...
credentials:diff Enrolls/disenrolls in decrypted diffs of credentials using git
credentials:edit Opens the decrypted credentials in `$EDITOR` for editing
credentials:show Shows the decrypted credentials
db:create Creates the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use...
db:drop Drops the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use d...
...
db:fixtures:load Loads fixtures into the current environment's database
db:migrate Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
db:migrate:down Runs the "down" for a given migration VERSION
db:migrate:redo Rolls back the database one migration and re-migrates up (options: STEP=x, VERSION=x)
db:migrate:up Runs the "up" for a given migration VERSION
db:prepare Runs setup if database does not exist, or runs migrations if it does
db:reset Drops and recreates all databases from their schema for the current environment and loads th...
db:rollback Rolls the schema back to the previous version (specify steps w/ STEP=n)
db:schema:cache:clear Clears a db/schema_cache.yml file
db:schema:cache:dump Creates a db/schema_cache.yml file
db:schema:dump Creates a database schema file (either db/schema.rb or db/structure.sql, depending on `ENV['...
db:schema:load Loads a database schema file (either db/schema.rb or db/structure.sql, depending on `ENV['SC...
db:seed Loads the seed data from db/seeds.rb
db:seed:replant Truncates tables of each database for current environment and loads the seeds
db:setup Creates all databases, loads all schemas, and initializes with the seed data (use db:reset t...
db:system:change Changes `config/database.yml` and your database gem to the target database
db:version Retrieves the current schema version number
destroy Removes code generated by `bin/rails generate`
dev:cache Toggles development mode caching on/off
encrypted:edit Opens the decrypted file in `$EDITOR` for editing
encrypted:show Shows the decrypted contents of the file
...
log:clear Truncates all/specified *.log files in log/ to zero bytes (specify which logs with LOGS=test...
middleware Prints out your Rack middleware stack
notes Shows comments in your code annotated with FIXME, OPTIMIZE, and TODO
...
routes Lists all the defined routes
runner Runs Ruby code in the context of your application
...
secrets:edit Opens the secrets in `$EDITOR` for editing
secrets:show Shows the decrypted secrets
...
tmp:create Creates tmp directories for cache, sockets, and pids
version Shows the Rails version
...
zeitwerk:check Checks project structure for Zeitwerk compatibility
```
__After__
```console
$ bin/rails --help
...
action_mailbox:install Install Action Mailbox and its dependencies
...
app:template Apply the template supplied by LOCATION=(/path/to/template) or URL
...
credentials:diff Enrolls/disenrolls in decrypted diffs of credentials using git
credentials:edit Opens the decrypted credentials in `$EDITOR` for editing
credentials:show Shows the decrypted credentials
db:create Create the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use ...
db:drop Drop the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db...
...
db:fixtures:load Load fixtures into the current environment's database
db:migrate Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
db:migrate:down Run the "down" for a given migration VERSION
db:migrate:redo Roll back the database one migration and re-migrate up (options: STEP=x, VERSION=x)
db:migrate:status Display status of migrations
db:migrate:up Run the "up" for a given migration VERSION
db:prepare Run setup if database does not exist, or run migrations if it does
db:reset Drop and recreate all databases from their schema for the current environment and load the s...
db:rollback Roll the schema back to the previous version (specify steps w/ STEP=n)
db:schema:cache:clear Clear a db/schema_cache.yml file
db:schema:cache:dump Create a db/schema_cache.yml file
db:schema:dump Create a database schema file (either db/schema.rb or db/structure.sql, depending on `ENV['S...
db:schema:load Load a database schema file (either db/schema.rb or db/structure.sql, depending on `ENV['SCH...
db:seed Load the seed data from db/seeds.rb
db:seed:replant Truncate tables of each database for current environment and load the seeds
db:setup Create all databases, load all schemas, and initialize with the seed data (use db:reset to a...
db:system:change Change `config/database.yml` and your database gem to the target database
db:version Retrieve the current schema version number
destroy Remove code generated by `bin/rails generate`
dev:cache Toggle development mode caching on/off
encrypted:edit Open the decrypted file in `$EDITOR` for editing
encrypted:show Show the decrypted contents of the file
...
log:clear Truncate all/specified *.log files in log/ to zero bytes (specify which logs with LOGS=test...
middleware Print out your Rack middleware stack
notes Show comments in your code annotated with FIXME, OPTIMIZE, and TODO
...
routes List all the defined routes
runner Run Ruby code in the context of your application
...
secrets:edit Open the secrets in `$EDITOR` for editing
secrets:show Show the decrypted secrets
...
tmp:create Create tmp directories for cache, sockets, and pids
version Show the Rails version
...
zeitwerk:check Check project structure for Zeitwerk compatibility
```
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
* Logging to a file doesn't make sense in production
You're going to run out of space, and it doesn't play well with containers. Either you log to STDOUT, and let your container setup aggregate the logs, or you'll be switching to syslogger or whatever. You won't be logging to a file in production any more.
* Remove from Dockerfile too
* Did not mean to change this default
But we should make it easy to see how to change it.
* Restore what we had
Previously, trying to `require "action_mailbox"` would fail if Active
Support was not previously required.
This fixes requiring Action Mailbox by adding the standard
"active_support" and "active_support/rails" requires. In addition, this
files uses `30.days` and so it needs to require core_ext/numeric/time as
well.
Since most of the ingress controllers receive raw MIME data in POST body,
it is impossible to guaratee that these are in UTF-8 as email comes in all
possible encodings.
This patch disables force transcoding to UTF-8 by ActionController params
processing for params that contain RAW MIME email bodies.
Fix#46297
`Mail` gem is an external gem and all methods extended by Rails
are undocumented. However it's listed in API document page.
It serves no purposes so it should be removed.
* Use storage/ instead of db/ for sqlite3 db files
db/ should be for configuration only, not data. This will make it easier to mount a single volume into a container for testing, development, and even sqlite3 in production.
Since engine initializers run later in the process, we need to run this
initializer earlier than the default.
This ensures they're all registered before the environments are loaded.
This commit adds `ActionMailbox.deprecator`, and adds it to
`Rails.application.deprecators` so that it can be configured via
settings such as `config.active_support.report_deprecations`.
Commit 37d1429ab1d introduced the DummyERB to avoid loading the environment when
running `rake -T`.
The DummyCompiler simply replaced all output from `<%=` with a fixed string and
removed everything else. This worked okay when it was used for YAML values.
When using `<%=` within a YAML key, it caused an error in the YAML parser,
making it impossible to use ERB as you would expect. For example a
`database.yml` file containing the following should be possible:
development:
<% 5.times do |i| %>
shard_<%= i %>:
database: db/development_shard_<%= i %>.sqlite3
adapter: sqlite3
<% end %>
Instead of using a broken ERB compiler we can temporarily use a
`Rails.application.config` that does not raise an error when configurations are
accessed which have not been set as described in #35468.
This change removes the `DummyCompiler` and uses the standard `ERB::Compiler`.
It introduces the `DummyConfig` which delegates all known configurations to the
real `Rails::Application::Configuration` instance and returns a dummy string for
everything else. This restores the full ERB capabilities without compromising on
speed when generating the rake tasks for multiple databases.
Deprecates `config.active_record.suppress_multiple_database_warning`.
Since Puma 5.0 (puma/puma@05936689c8),
Puma will automatically set `workers` to `ENV["WEB_CONCURRENCY"] || 0`.
Additionally, if `ENV["WEB_CONCURRENCY"]` > 1, Puma will automatically
set `preload_app`.
This can lead to confusing scenarios for users who are unaware of this
behavior and have customized `config/puma.rb`. For example, if a user
uncomments the `workers` and `preload_app!` directives, it is clear that
Puma will preload the app, and the number of workers can be configured
by setting `ENV["WEB_CONCURRENCY"]`. If the user sets
`ENV["WEB_CONCURRENCY"]` > 1, but then changes their mind and removes
the `workers` or `preload_app!` directives *without* clearing
`ENV["WEB_CONCURRENCY"]`, Puma will still preload the app and launch
`ENV["WEB_CONCURRENCY"]` number of workers. Similarly, if a user
uncomments *only* the `workers` directive and sets
`ENV["WEB_CONCURRENCY"]` > 1, Puma will preload the app even though the
`preload_app!` directive is still commented out.
To avoid such scenarios, this commit removes the commented-out `workers`
and `preload_app!` directives from the default `config/puma.rb`.
Also, to improve discoverability of available configuration options,
this commit adds a link to the Puma DSL documentation at the top of the
file.
I was auditing which routes in my app do not actually a
have corresponding controller action. ActionMailbox's
inbound_mails has these 4 routes defined, which do not
actually work.
GET /rails/conductor/action_mailbox/inbound_emails/:id/edit
PATCH /rails/conductor/action_mailbox/inbound_emails/:id
PUT /rails/conductor/action_mailbox/inbound_emails/:id
DELETE /rails/conductor/action_mailbox/inbound_emails/:id
I wanted to add a test for sending an attachment that is an empty string
and a file but got this error:
NoMethodError: undefined method `original_filename' for "#<Rack::Test::UploadedFile:0x000000010840d388>":String
Related: #44702Fixes#45088
-----
Started POST "/rails/conductor/action_mailbox/inbound_emails" for ::1 at 2022-05-14 07:34:19 +0200
Processing by Rails::Conductor::ActionMailbox::InboundEmailsController#create as HTML
Parameters: {"authenticity_token"=>"[FILTERED]", "mail"=>{"from"=>"", "to"=>"", "cc"=>"", "bcc"=>"", "x_original_to"=>"", "in_reply_to"=>"", "subject"=>"", "body"=>"", "attachments"=>[""]}, "commit"=>"Deliver inbound email"}
Completed 500 Internal Server Error in 7ms (ActiveRecord: 0.0ms | Allocations: 2600)
NoMethodError (undefined method `original_filename' for "":String
mail.add_file(filename: attachment.original_filename, content: attachment.read)
^^^^^^^^^^^^^^^^^^):
actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:26:in `block (2 levels) in new_mail'
actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:25:in `each'
actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:25:in `block in new_mail'
<internal:kernel>:90:in `tap'
actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:23:in `new_mail'
actionmailbox (7.0.3) app/controllers/rails/conductor/action_mailbox/inbound_emails_controller.rb:17:in `create'
Co-Authored-By: Patrício dos Santos <hello@psantos.dev>
Every time I write `config.cache_classes` I have to pause for a moment to make
sure I get it right. It makes you think.
On the other hand, if you read `config.enable_reloading = true`, does the
application reload? You do not need to spend 1 cycle of brain CPU to nod.
Calling `skip_forgery_protection` without first calling
`protect_from_forgery`--either manually or through default
settings--raises an `ArgumentError` because `verify_authenticity_token`
has not been defined as a callback.
Since Rails 7.0 adds `skip_forgery_protection` to the
`Rails::WelcomeController` (PR #42864), this behavior means that setting
`default_protect_from_forgery` to false and visiting the Rails Welcome
page (`/`) raises an error.
This behavior also created an issue for `ActionMailbox` that was
previously fixed in the Mailbox controller by running
`skip_forgery_protection` only if `default_protect_from_forgery` was
true (PR #35935).
This PR addresses the underlying issue by setting the `raise` option for
`skip_before_action` to default to false inside
`skip_forgery_protection`.
The fix is implemented in `request_forgery_protection.rb`. The change to
`ActionMailbox`'s `base_controller.rb` removes the now-unnecessary
check of `default_protect_from_forgery`.
The tests added in `request_forgery_protection_test.rb` and
`routing_test.rb` both raise an error when run against the current
codebase and pass with the changes noted above.