This has the benefit of hiding the warning message from git when
initialBranch configuration is unset, and was a recommendation on the
original commit adding main as the default branch for generators.
Ref: eb261937ac856100b4e1c8a2dbb56aab6e5d140e
Rendering the list of boot steps as a code block confused the syntax
highlighter.
This commit changes the list to use RDoc's ordered list syntax, and adds
inline code markup as appropriate.
This almost never matters, but if the path-global 'rake' or 'rails'
points to a specific (and wrong) ruby version, (or, possible in CI,
there is no installed 'rails' executable), things get confused.
Instead, any time we mean "run a global 'rails', as for 'new'", use a
fully-qualified path to our in-tree copy. And any time we're working
inside an application, use the bin/rails script directly. It would be
equivalently valid to always use the one in exe/, because that handles
searching for bin/rails internally... but it's uglier to fully-qualify,
plus 'rake' would then be more complicated.
These changes include adding a hybrid serializer class
named JsonWithMarshalFallback in order for existing apps
to have an upgrade path from Marshal to JSON.
The old code does
@foo.destroy
redirect_to foo_url, notice: "Foo was successfully destroyed."
which would incorrectly state the record was destroyed even if prevented
by a `before_destroy` callback.
The new version would raise.
Add some missing punctuation marks and make permissions_policy more
consistent with other initializers.
Also rename the `f` variable to the more clearer `policy` similar to
content_security_policy.rb.
There is still some confusion about how contributors should communicate
versioned default values. Now that each configuration setting has its
own heading (since #43138), it seems appropriate that each setting's
section be self-contained. Therefore, this commit moves each versioned
default value into its respective section.
This also adds a few configuration setting descriptions and baseline
default values that were missing.
This commit refactors the plugin `Gemfile.tt` to abstract much of the
logic into the `gemfile_entries` helper. Doing so avoids adding
duplicate `Gemfile` entries (e.g. `gem "sqlite3"`), as well as
application-only `Gemfile` entries (e.g. `gem "puma"`), when generating
a plugin with a prerelease flag (e.g. `--dev`).
To fix#43920, f292daad7051275f7b557b352876cfeb3988f639 added
`sprockets-rails` to the generated `Gemfile` for engine plugins because
their dummy apps use Sprockets. However, non-engine plugins exhibit the
same issue because their dummy apps also use Sprockets.
This commit forces `skip_asset_pipeline` to be true when a plugin is not
an engine, and fixes several tests that failed to detect these issues
because they were accidentally using the `rails/rails` `Gemfile` instead
of the generated plugin `Gemfile`.
Follow-up to #41584.
Thor uses a regexp with its own capture groups when revoking an
`inject_into_file` call. Thus an `:after` regexp containing capture
groups will interfere with Thor's regexp.
This commit changes the `:after` regexp we pass to `inject_into_file`
so that it no longer contains capture groups. This commit also cleans
up any newly-empty namespace blocks when revoking a route, since
`inject_into_file` does not handle that.
The majority of this commit is refactoring and clean-up. The actual
regexp fix is just the following line:
```ruby
namespace_pattern = /#{Regexp.escape namespace_match.to_s}/
```
Fixes#43950.
It's possible that applications using a 3-tier config don't have a
"primary" database entry. When booting the db console we should take the
first database, not assume there's a primary.
This also changes the message to be more clear. If no database is
provided and there are no databases for the environment we shouldn't
say that "primary" didn't exist - instead it should say no databases
exist.
Due to a conflict between #43846 and #43611, the variable name generated
inside the `each` block did not match the block parameter name for
namespaced models. For example, if the block parameter name was
`admin_role`, the variable name inside the block would be just `role`.
This commit changes `index.html.erb` to use the correct variable name,
and adds much more test coverage.
This commit also changes the target for the "Destroy" button rendered
in `show.html.erb` from a route helper call to a bare model reference,
e.g. from `admin_role_path(@admin_role)` to just `@admin_role`. This
was missed in #43611.
Squashed commit of the following:
Tweaks
Extend test adding more assertions
Update scaffold generator test and add application generator test for controller generator with namespace
Adapt code to feedback suggestions
Apply suggestions from code review
Run generated tests by scaffold controller generator
Fix generated tests too
Keep generated url helpers consistent
Fix scaffold controller generator with namespace
For example:
```
bundle exec rails g scaffold_controller Admin::Post title:string content:text --model-name=Post
```
It fixes the code generated by railties, other changes are required on
jbuilder gem.
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
Co-authored-by: José Galisteo <ceritium@gmail.com>
* Generated Gemfile will automatically pickup the latest version on first bundle
No need to prescribe the lower boundary for a newly generated Gemfile, since the first bundle will automatically lock-in the latest version.
* Elevating floating entries with explaining factory method
* Trailing space
The background
---
Configuration for replacing a collection was introduced in
[rails/rails#36716][].
However, since [rails/rails#42596][] has been merged, Rails 7.1 and
beyond will default to _replacing_ an Active Storage `has_many_attached`
relationship, as opposed to _appending to it_.
The problem
---
With replacement as the established precedent, it's currently a
challenge to replace an existing collection with an empty one.
The solution
---
This commit makes two changes.
The first is to Action View and its form building helpers. The change
draws inspiration from how an `<input type="checkbox">` field (or
collection of fields) is paired with an `<input type="hidden">` field to
represent the unchecked value. The change pairs any `<input type="file"
multiple="multiple">` elements with an `<input type="hidden">` element
to represent an empty collection. Like the [check_box][] form builder
method, the `file_field` method accepts an `include_hidden:` option to
skip the creation of the hidden element.
The second is to how Active Storage generates attribute assignment
methods through `has_many_attached`. With the possibility of an `<input
type="file">` field being paired with an `<input type="hidden"
value="">` field, the backing models need to be able to coerce an
"empty-ish" value into an empty list. For example:
```ruby
@user.highlights = [""]
@user.highlights # => []
```
When combined, these changes enable consumer applications to submit
"empty" collections to blank out existing attachments.
Support is configured through the
`config.active_storage.multiple_file_field_include_hidden` configuration
value, which defaults to `false`.
[check_box]: https://edgeapi.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html#method-i-check_box
[rails/rails#36716]: https://github.com/rails/rails/pull/36716
[rails/rails#42596]: https://github.com/rails/rails/pull/42596