Commit Graph

2615 Commits

Author SHA1 Message Date
John Hawthorn
85ecf6e409 Remove support for templates with "."
This was previously deprecated in Rails 6.1 (and never quite behaved
correctly)
2021-04-14 11:27:11 -07:00
Zachary Scott
43e29f0f5d
Merge pull request #41945 from jbampton/fix-grammar
chore: fix grammar, spelling and minor whitespace fix
2021-04-14 09:19:15 +09:00
John Hawthorn
997c76cf80 Resolve wildcards depends using all_template_paths
This switches wildcard dependencies from using its custom
find_all_with_query method to use all_template_paths, the same method
now used for DidYouMean template suggestions.

This also removes related cache for wildcard queries. Since it was only
used during digesting, the digest cache should be sufficient.
2021-04-13 15:04:17 -07:00
John Hawthorn
6d11711042 Refactor suggestions into all_template_paths 2021-04-13 15:04:16 -07:00
John Bampton
4075b5b884
Fix spelling in FixtureResolverTest 2021-04-13 10:46:09 -04:00
John Bampton
54e526e473 chore: fix grammar, spelling and minor whitespace fix 2021-04-13 21:35:50 +10:00
Rafael Mendonça França
4354e3ae49
Don't define methods using the method modifier in the same line as the method
Our style guide use block method modifiers, not inline method modifiers.
2021-04-12 18:49:54 +00:00
John Bampton
44c32c1605 chore: remove redundant MIME type from HTML script tag
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
2021-04-12 06:57:03 +10:00
Jean Boussier
3f59640016 Stop checking if ruby2_keywords is defined 2021-04-11 13:42:02 +02:00
Ryuta Kamizono
3b1fae47db
Merge pull request #41886 from jacobherrington/add-example-for-params-button-to-doc
Add example of params to button_to docs [ci skip]
2021-04-09 11:09:17 +09:00
Jacob Herrington
4bfc35a4f9
Add example of params to button_to docs [ci skip]
Also, this commit updates the output in the examples to include the
authenticity token because it is rendered in all of the examples.
2021-04-08 14:19:56 -05:00
John Hawthorn
6fa9cd88b9 Add DidYouMean suggestions for missing templates
Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
2021-04-07 09:18:12 -07:00
John Hawthorn
fb6b0a51b3 Remove FallbackFileSystemResolver
This removes FallbackFileSystemResolver, LookupContext#with_fallbacks,
and LookupContext.fallbacks.

These used to exist to support `render file:`, and rendering templates
outside of the defined view paths. `render file:` has since been changed
to not use template resolution, and to only render absolute paths.

These were no longer callable through any public API.
2021-04-06 14:20:48 -07:00
Ryuta Kamizono
c7a036c2b6 Revert "Passing in a Hash instance as non-kwargs parameters has to be curly braced now"
This reverts commit d2f4541f126001e029078cc48a3a481e23ae3ed9.

It should work without curly braces.

See also: #41198, #41206, 81d90d81d0ee1fc1a649ab705119a71f2d04c8a2.
2021-03-22 11:21:33 +09:00
Ryuta Kamizono
81d90d81d0 Allow both current_page?(url_hash) and current_page?(**url_hash) on Ruby 2.7
Keyword argument warnings are caused by #41206 to allow both
`current_page?(url_hash)` and `current_page?(**url_hash)` on Ruby 3.0.

Unfortunately it is super hard to support that for both Ruby 2.7 and 3.0
with the same method signature.

Closes #41710.
2021-03-22 10:57:45 +09:00
Máximo Mussini
1598ad5c4b
Ensure modules are preloaded correctly using rel=modulepreload.
Prior to this change, javascript_include_tag was sending a hint using
rel="preload" for all scripts, including those of type="module".

This causes the browser to make a request to preload the script, but
because the rel is incorrect, it won't be able to reuse it.

When passing type="module", it should use rel=modulepreload instead.

[0] developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content
[1] developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link
[2] developer.mozilla.org/en-US/docs/Web/HTML/Link_types/modulepreload
2021-03-19 13:22:22 -04:00
Alex Ghiculescu
0fba70c082 Clarify when enctype="multipart/form-data" gets added to forms [docs]
As noted in https://github.com/rails/rails/issues/41632 the docs for this are incorrect. The `enctype` attribute is automatically added anytime you make a form with a `file_field`.

Resolves https://github.com/rails/rails/issues/41632

Update actionview/lib/action_view/helpers/form_helper.rb

Co-authored-by: Petrik de Heus <petrik@deheus.net>
2021-03-10 13:09:46 -06:00
Sohaib Talaat Bhatti
3f3f7af9e8 Fix phone_to API documentation sample output 2021-03-05 17:05:24 +05:00
Austen Madden
986cdba7d2 Clarify button_to html_options documentation
Further explain how html_options can be used in button_to. Specifically
with regard to html_options passed to the button (form submit) element.
2021-03-01 09:54:25 -05:00
Carlos Antonio da Silva
3875e07f3c Simplify formmethod checks on button_to for non-GET/POST handling
* Check for the presence of `formmethod` first before checking against
  the GET/POST verbs;
* Use `match?` to avoid creating unnecessary match objects;
* Remove capture groups from the verb regexp.
2021-02-22 10:08:48 -03:00
Rafael França
89b52a8dd3
Merge pull request #41472 from Shopify/stylesheet-duplicated-media
Fix the duplicated media attribute in stylesheet_link_tag
2021-02-17 10:09:48 -05:00
Jean Boussier
1b70109aee Fix the duplicated media attribute in stylesheet_link_tag 2021-02-17 11:34:39 +01:00
Petrik
9ecae8336f Update Rails version in depraction and add non-deprecated code
Passing instance variables to `render` will be deprecated in the next
version, which is Rails 7.1.
Also add the non-deprecated implementation, which removes `@?` from the
Regexp, to make removal of the deprecation easier.
2021-02-17 09:41:37 +01:00
Rafael França
fe912cb1a7
Merge pull request #41464 from p8/deprecate-ivars-locals-in-render-partial
Deprecate render locals to be assigned to instance variables
2021-02-16 14:24:59 -05:00
Petrik
96d72d9b25 Deprecate render locals to be assigned to instance variables
Rails partial rendering allows assigning instance variables.
For example:

  render 'partial', :@name => "Maceo"

This sets @name to "Maceo" on the ActionView::Base object.

The allowed instance variables aren't restricted to the user's defined
instance variables but can also override private Rails variables like
@_assigns, @output_buffer, @_config, and @_default_form_builder.
2021-02-16 20:06:59 +01:00
Rafael França
a642b7c02b
Merge pull request #41450 from jonathanhefner/sms_to-improve-api-doc
Improve sms_to API documentation [ci-skip]
2021-02-15 18:52:18 -05:00
Rafael França
3c63f57a5c
Merge pull request #41451 from jonathanhefner/mail_to-support-options-when-no-name
Support mail_to options when name not specified
2021-02-15 18:51:51 -05:00
Rafael França
6834102840
Merge pull request #41449 from jonathanhefner/sms_to-support-options-when-no-name
Support sms_to options when name not specified
2021-02-15 18:51:32 -05:00
Jonathan Hefner
5b8fee1be1 Improve sms_to API documentation [ci-skip]
This tightens the prose a bit.
2021-02-15 11:42:12 -06:00
Jonathan Hefner
96106d80aa
Merge pull request #41444 from jonathanhefner/phone_to-improve-api-doc
Improve phone_to API documentation [ci-skip]
2021-02-15 11:18:17 -06:00
Jonathan Hefner
4f1f63b98a
Merge pull request #41441 from jonathanhefner/apidocs-inline-code-markup
Fix inline code markup [ci-skip]
2021-02-15 11:16:44 -06:00
Jonathan Hefner
63edd5cd2f Improve phone_to API documentation [ci-skip]
This tightens the prose, and fixes grammar, typos, and code markup.
2021-02-15 11:07:22 -06:00
Jonathan Hefner
e2f998ab49 Support mail_to options when name not specified
When `name` is not specified, `mail_to` uses `email_address` as the link
text.  This commit allows options to be specified in such a case.
2021-02-15 10:27:04 -06:00
Jonathan Hefner
2a24a3c9c0 Support sms_to options when name not specified
When `name` is not specified, `sms_to` uses `phone_number` as the link
text.  This commit allows options to be specified in such a case.
2021-02-15 10:17:39 -06:00
Jonathan Hefner
3938363494 Support phone_to options when name not specified
When `name` is not specified, `phone_to` uses `phone_number` as the link
text.  This commit allows options to be specified in such a case.  This
enables using the `country_code` option to include the country code in
the link `href`, while a country-code-less `phone_number` is used as the
link text.
2021-02-14 15:40:33 -06:00
Jonathan Hefner
167f5c8065 Fix inline code markup [ci-skip]
RDoc Markup does not support backticks the way Markdown does to mark up
inline code.  Additionally, `<tt>` must be used to mark up inline code
that includes spaces or certain punctuation characters (e.g. quotes).
2021-02-14 11:20:35 -06:00
T.J. Schuck
c80df59b25 Fix formatting in highlight docs
Right now, the `\1` in the plain text gets escaped to just "1" in the rendered docs.  Wrap it in `tt` tags to keep the \ there as intended.

[ci skip]
2021-02-11 16:48:45 -05:00
Ryuta Kamizono
7b680baea2 Remove require "active_support/core_ext/symbol/starts_ends_with"
Ruby 2.7 has native `Symbol#start_with?` and `Symbol#end_with?`.
2021-02-09 22:31:09 +09:00
Ryuta Kamizono
7dd4dde53d Remove all version checking for older Rubies in tests
Code cleanup for tests.
2021-02-05 13:21:45 +09:00
Rafael Mendonça França
1b455e2e9d
Rails 6.2 is now Rails 7.0
We have big plans for the next version of Rails and that
require big versions.
2021-02-04 16:47:16 +00:00
Rafael Mendonça França
6487836af8
Rails 7 requires Ruby 2.7 and prefer Ruby 3+
The code cleanup is comming in later commits but this
already remove support to Ruby < 2.7.
2021-02-04 16:34:53 +00:00
Yasuo Honda
40db515e91 Address warning: Passing only keyword arguments
This pull request addresses the following warnings enabled since ruby/ruby#4070

* Warnings without this fix 1

```
% ruby -v
ruby 3.1.0dev (2021-02-01T10:54:21Z master 1cdae49d39) [x86_64-darwin20]
% bin/test test/cases/arel/visitors/sqlite_test.rb:36
... snip ...
/Users/yahonda/src/github.com/rails/rails/activerecord/test/cases/arel/support/fake_record.rb:98: warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).
.

Finished in 0.003538s, 2261.1645 runs/s, 2543.8101 assertions/s.
8 runs, 9 assertions, 0 failures, 0 errors, 0 skips
%
```

* Warnings without this fix 2

```ruby
% ruby -v
ruby 3.1.0dev (2021-02-01T10:54:21Z master 1cdae49d39) [x86_64-darwin20]
% bin/test test/cases/type/adapter_specific_registry_test.rb
Using sqlite3
Run options: --seed 53175

......./Users/yahonda/src/github.com/rails/rails/activerecord/test/cases/type/adapter_specific_registry_test.rb:126: warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).
/Users/yahonda/src/github.com/rails/rails/activemodel/lib/active_model/type/registry.rb:18: warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).
/Users/yahonda/src/github.com/rails/rails/activerecord/test/cases/type/adapter_specific_registry_test.rb:130: warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).
/Users/yahonda/src/github.com/rails/rails/activemodel/lib/active_model/type/registry.rb:18: warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).
.../Users/yahonda/src/github.com/rails/rails/activerecord/test/cases/type/adapter_specific_registry_test.rb:85: warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).
/Users/yahonda/src/github.com/rails/rails/activemodel/lib/active_model/type/registry.rb:18: warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).
/Users/yahonda/src/github.com/rails/rails/activerecord/test/cases/type/adapter_specific_registry_test.rb:86: warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).
/Users/yahonda/src/github.com/rails/rails/activemodel/lib/active_model/type/registry.rb:18: warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).
.

Finished in 0.011424s, 962.8852 runs/s, 2450.9804 assertions/s.
11 runs, 28 assertions, 0 failures, 0 errors, 0 skips
%
```

* Warnings without this fix 3

```ruby
$ cd actionview
$ bin/test test/template/url_helper_test.rb
Run options: --seed 27105

........................../home/yahonda/src/github.com/rails/rails/actionview/test/template/url_helper_test.rb:88: warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).
.............................../home/yahonda/src/github.com/rails/rails/actionview/test/template/url_helper_test.rb:94: warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).
..................................................../home/yahonda/src/github.com/rails/rails/actionview/test/template/url_helper_test.rb:71: warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).
......................

Finished in 0.305066s, 429.4159 runs/s, 580.2032 assertions/s.
131 runs, 177 assertions, 0 failures, 0 errors, 0 skips
$
```

Refer:
ruby/ruby#4070
https://bugs.ruby-lang.org/issues/16806

Co-authored-by: Ryuta Kamizono <kamipo@gmail.com>
2021-02-02 21:59:08 +09:00
Ryuta Kamizono
c38db72472 Fix CI failure due to app.config.action_view.delete(:apply_apply_stylesheet_media_default)
https://buildkite.com/rails/rails/builds/74429#3de35026-a6dc-4f4c-b885-9b59e0c89b96/979-1036
2021-01-27 10:40:54 +09:00
Rafael Mendonça França
bf545b73b7
Add CHANGELOG entry for #41215 2021-01-27 00:33:12 +00:00
Rafael Mendonça França
033706b2dc
Rename the config to make clear it is a boolean 2021-01-27 00:31:16 +00:00
Rafael França
b623ee988c
Merge pull request #41215 from andrehjr/remove-legacy-media-screen
Remove legacy default media=screen from stylesheet_link_tag
2021-01-26 19:06:58 -05:00
Brandon Fish
7f2c6a87fe Update test helper to call parallelize according to fork support 2021-01-25 13:50:41 -06:00
André Luis Leal Cardoso Junior
1280620767 Remove legacy media=screen default from stylesheet_link_tag.
If the media attribute is omitted, the default for web browsers is "all", meaning that by default links apply to all media.

Before:

```ruby
> stylesheet_link_tag "style"
=> <link href="/assets/style.css" media="screen" rel="stylesheet" />
```

After:

```ruby
> stylesheet_link_tag "style"
=> <link href="/assets/style.css" rel="stylesheet" />

```

The current behavior is not going to change for existing applications.

For newly built applications, the media attribute is not going to be added by default. Which can be configured using the following:

```
Rails.application.config.action_view.stylesheet_media_default = false
```
2021-01-22 20:42:22 -03:00
Jacopo
3d76418b9d Fix current_page? with kwargs on ruby3
Prevent raising an error when `options` are given as
kwargs, this is done by overriding `options` with kwargs
if `options` are `nil`; this implies that if both `options` and
kwargs are given, `options` takes precedence.

Fixes #41198
2021-01-22 12:16:16 +01:00
Rafael Mendonça França
077c66d5d6
Rename master to main in all code references 2021-01-19 20:46:33 +00:00