mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Some improvements in the 5.1 release notes [ci skip]
This commit is contained in:
parent
eac6f3690f
commit
80c58a8d90
1 changed files with 32 additions and 28 deletions
|
@ -40,7 +40,7 @@ Major Features
|
||||||
|
|
||||||
[Pull Request](https://github.com/rails/rails/pull/26836)
|
[Pull Request](https://github.com/rails/rails/pull/26836)
|
||||||
|
|
||||||
Rails 5.1 will allow managing JavaScript dependencies
|
Rails 5.1 allows managing JavaScript dependencies
|
||||||
from NPM via Yarn. This will make it easy to use libraries like React, VueJS
|
from NPM via Yarn. This will make it easy to use libraries like React, VueJS
|
||||||
or any other library from NPM world. The Yarn support is integrated with
|
or any other library from NPM world. The Yarn support is integrated with
|
||||||
the asset pipeline so that all dependencies will work seamlessly with the
|
the asset pipeline so that all dependencies will work seamlessly with the
|
||||||
|
@ -70,14 +70,14 @@ offerings. It is no longer required, as the UJS has been rewritten to use plain,
|
||||||
vanilla JavaScript. This code now ships inside of Action View as
|
vanilla JavaScript. This code now ships inside of Action View as
|
||||||
`rails-ujs`.
|
`rails-ujs`.
|
||||||
|
|
||||||
You can still use the jQuery version if needed, but it is no longer required by default.
|
You can still use jQuery if needed, but it is no longer required by default.
|
||||||
|
|
||||||
### System tests
|
### System tests
|
||||||
|
|
||||||
[Pull Request](https://github.com/rails/rails/pull/26703)
|
[Pull Request](https://github.com/rails/rails/pull/26703)
|
||||||
|
|
||||||
Rails 5.1 has baked-in support for writing Capybara tests, in the form of
|
Rails 5.1 has baked-in support for writing Capybara tests, in the form of
|
||||||
System tests. You need no longer worry about configuring Capybara and
|
System tests. You no longer need to worry about configuring Capybara and
|
||||||
database cleaning strategies for such tests. Rails 5.1 provides a wrapper
|
database cleaning strategies for such tests. Rails 5.1 provides a wrapper
|
||||||
for running tests in Chrome with additional features such as failure
|
for running tests in Chrome with additional features such as failure
|
||||||
screenshots.
|
screenshots.
|
||||||
|
@ -86,7 +86,7 @@ screenshots.
|
||||||
|
|
||||||
[Pull Request](https://github.com/rails/rails/pull/28038)
|
[Pull Request](https://github.com/rails/rails/pull/28038)
|
||||||
|
|
||||||
Rails will now allow management of application secrets in a secure way,
|
Rails now allows management of application secrets in a secure way,
|
||||||
building on top of the [sekrets](https://github.com/ahoward/sekrets) gem.
|
building on top of the [sekrets](https://github.com/ahoward/sekrets) gem.
|
||||||
|
|
||||||
Run `bin/rails secrets:setup` to setup a new encrypted secrets file. This will
|
Run `bin/rails secrets:setup` to setup a new encrypted secrets file. This will
|
||||||
|
@ -106,33 +106,24 @@ order to share instance variables, headers and other common setup.
|
||||||
|
|
||||||
``` ruby
|
``` ruby
|
||||||
class InvitationsMailer < ApplicationMailer
|
class InvitationsMailer < ApplicationMailer
|
||||||
|
|
||||||
before_action { @inviter, @invitee = params[:inviter], params[:invitee] }
|
before_action { @inviter, @invitee = params[:inviter], params[:invitee] }
|
||||||
before_action { @account = params[:inviter].account }
|
before_action { @account = params[:inviter].account }
|
||||||
|
|
||||||
def account_invitation
|
def account_invitation
|
||||||
mail subject: "#{@inviter.name} invited you to their Basecamp (#{@account.name})"
|
mail subject: "#{@inviter.name} invited you to their Basecamp (#{@account.name})"
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_invitation
|
|
||||||
@project = params[:project]
|
|
||||||
@summarizer = ProjectInvitationSummarizer.new(@project.bucket)
|
|
||||||
|
|
||||||
mail subject: "#{@inviter.name.familiar} added you to a project in Basecamp (#{@account.name})"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
InvitationsMailer.with(inviter: person_a, invitee: person_b).account_invitation.deliver_later
|
InvitationsMailer.with(inviter: person_a, invitee: person_b)
|
||||||
|
.account_invitation.deliver_later
|
||||||
```
|
```
|
||||||
|
|
||||||
### Direct & resolved routes
|
### Direct & resolved routes
|
||||||
|
|
||||||
[Pull Request](https://github.com/rails/rails/pull/23138)
|
[Pull Request](https://github.com/rails/rails/pull/23138)
|
||||||
|
|
||||||
Rails 5.1 has added two new methods, `resolve` and `direct`, to the routing
|
Rails 5.1 adds two new methods, `resolve` and `direct`, to the routing
|
||||||
DSL.
|
DSL. The `resolve` method allows customizing polymorphic mapping of models.
|
||||||
|
|
||||||
The `resolve` method allows customizing polymorphic mapping of models.
|
|
||||||
|
|
||||||
``` ruby
|
``` ruby
|
||||||
resource :basket
|
resource :basket
|
||||||
|
@ -181,44 +172,57 @@ Before Rails 5.1, there were two interfaces for handling HTML forms:
|
||||||
Rails 5.1 combines both of these interfaces with `form_with`, and
|
Rails 5.1 combines both of these interfaces with `form_with`, and
|
||||||
can generate form tags based on URLs, scopes or models.
|
can generate form tags based on URLs, scopes or models.
|
||||||
|
|
||||||
``` erb
|
Using just a URL:
|
||||||
# Using just a URL:
|
|
||||||
|
|
||||||
|
``` erb
|
||||||
<%= form_with url: posts_path do |form| %>
|
<%= form_with url: posts_path do |form| %>
|
||||||
<%= form.text_field :title %>
|
<%= form.text_field :title %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
# =>
|
<%# Will generate %>
|
||||||
|
|
||||||
<form action="/posts" method="post" data-remote="true">
|
<form action="/posts" method="post" data-remote="true">
|
||||||
<input type="text" name="title">
|
<input type="text" name="title">
|
||||||
</form>
|
</form>
|
||||||
|
```
|
||||||
|
|
||||||
# Adding a scope prefixes the input field names:
|
Adding a scope prefixes the input field names:
|
||||||
|
|
||||||
|
``` erb
|
||||||
<%= form_with scope: :post, url: posts_path do |form| %>
|
<%= form_with scope: :post, url: posts_path do |form| %>
|
||||||
<%= form.text_field :title %>
|
<%= form.text_field :title %>
|
||||||
<% end %>
|
<% end %>
|
||||||
# =>
|
|
||||||
|
<%# Will generate %>
|
||||||
|
|
||||||
<form action="/posts" method="post" data-remote="true">
|
<form action="/posts" method="post" data-remote="true">
|
||||||
<input type="text" name="post[title]">
|
<input type="text" name="post[title]">
|
||||||
</form>
|
</form>
|
||||||
|
```
|
||||||
|
|
||||||
# Using a model infers both the URL and scope:
|
Using a model infers both the URL and scope:
|
||||||
|
|
||||||
|
``` erb
|
||||||
<%= form_with model: Post.new do |form| %>
|
<%= form_with model: Post.new do |form| %>
|
||||||
<%= form.text_field :title %>
|
<%= form.text_field :title %>
|
||||||
<% end %>
|
<% end %>
|
||||||
# =>
|
|
||||||
|
<%# Will generate %>
|
||||||
|
|
||||||
<form action="/posts" method="post" data-remote="true">
|
<form action="/posts" method="post" data-remote="true">
|
||||||
<input type="text" name="post[title]">
|
<input type="text" name="post[title]">
|
||||||
</form>
|
</form>
|
||||||
|
```
|
||||||
|
|
||||||
# An existing model makes an update form and fills out field values:
|
An existing model makes an update form and fills out field values:
|
||||||
|
|
||||||
|
``` erb
|
||||||
<%= form_with model: Post.first do |form| %>
|
<%= form_with model: Post.first do |form| %>
|
||||||
<%= form.text_field :title %>
|
<%= form.text_field :title %>
|
||||||
<% end %>
|
<% end %>
|
||||||
# =>
|
|
||||||
|
<%# Will generate %>
|
||||||
|
|
||||||
<form action="/posts/1" method="post" data-remote="true">
|
<form action="/posts/1" method="post" data-remote="true">
|
||||||
<input type="hidden" name="_method" value="patch">
|
<input type="hidden" name="_method" value="patch">
|
||||||
<input type="text" name="post[title]" value="<the title of the post>">
|
<input type="text" name="post[title]" value="<the title of the post>">
|
||||||
|
@ -264,7 +268,7 @@ Please refer to the [Changelog][railties] for detailed changes.
|
||||||
### Removals
|
### Removals
|
||||||
|
|
||||||
* Remove deprecated `config.static_cache_control`.
|
* Remove deprecated `config.static_cache_control`.
|
||||||
([commit](https://github.com/rails/rails/commit/c861decd44198f8d7d774ee6a74194d1ac1a5a13)
|
([commit](https://github.com/rails/rails/commit/c861decd44198f8d7d774ee6a74194d1ac1a5a13))
|
||||||
|
|
||||||
* Remove deprecated `config.serve_static_files`.
|
* Remove deprecated `config.serve_static_files`.
|
||||||
([commit](https://github.com/rails/rails/commit/0129ca2eeb6d5b2ea8c6e6be38eeb770fe45f1fa))
|
([commit](https://github.com/rails/rails/commit/0129ca2eeb6d5b2ea8c6e6be38eeb770fe45f1fa))
|
||||||
|
@ -298,7 +302,7 @@ Please refer to the [Changelog][railties] for detailed changes.
|
||||||
* Add Yarn support in new apps with a yarn binstub and package.json.
|
* Add Yarn support in new apps with a yarn binstub and package.json.
|
||||||
([Pull Request](https://github.com/rails/rails/pull/26836))
|
([Pull Request](https://github.com/rails/rails/pull/26836))
|
||||||
|
|
||||||
* Add Webpack support in new apps via the --webpack option, which will delegate
|
* Add Webpack support in new apps via the `--webpack` option, which will delegate
|
||||||
to the rails/webpacker gem.
|
to the rails/webpacker gem.
|
||||||
([Pull Request](https://github.com/rails/rails/pull/27288))
|
([Pull Request](https://github.com/rails/rails/pull/27288))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue