| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| | |
Fix unexpected select_tag delete behavior when include_blank is present
|
| | |
|
|/
|
|
|
|
|
|
|
|
| |
The `number_to_human_size` helpers in Action View and Active Support
calculate the "human size" with a base of 1024. The examples should
reflect that so they don't confuse the reader.
The updated documentations use the values from:
helper.number_to_human_size(1500)
|
| |
|
| |
|
|
|
|
| |
Here is only place where we use `mb_chars` internally.
|
|\
| |
| | |
Ruby 2.7 warning: creating a Proc without a block
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As of [Revision 66772](
https://bugs.ruby-lang.org/projects/ruby-trunk/repository/trunk/revisions/66772)
`Proc.new` without giving a block emits `warning: tried to create Proc object without a block`.
This commit fixes cases where Rails test suit tickles this warning.
See CI logs:
https://travis-ci.org/rails/rails/jobs/487205819#L1161-L1190
https://travis-ci.org/rails/rails/jobs/487205821#L1154-1159
https://travis-ci.org/rails/rails/jobs/487205821#L1160-L1169
https://travis-ci.org/rails/rails/jobs/487205821#L1189
https://travis-ci.org/rails/rails/jobs/487254404#L1307-L1416
https://travis-ci.org/rails/rails/jobs/487254405#L1174-L1191
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
A string S matches ([.]|\b)html if an only if matches \bhtml:
* If S matches [.]html, then it matches \bhtml.
* If S matches \bhtml, then it matches \bhtml.
Reciprocally:
* If S matches \bhtml, then it matches ([.]|\b)html.
The character class can be removed, and since we are on it we remove the
group too so that it is clear to a reader of the code that there is no
grouping going on.
References #35166.
|
| |
| |
| |
| |
| |
| |
| | |
Templates only have one format. Before this commit, templates would be
constructed with a single element array that contained the format. This
commit eliminates the single element array and just implements a
`format` method. This saves one array allocation per template.
|
| | |
|
|\ \
| | |
| | | |
Pass the template format to the digestor
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This commit passes the template format to the digestor in order to come
up with a key. Before this commit, the digestor would depend on the
side effect of the template renderer setting the rendered_format on the
lookup context. I would like to remove that mutation, so I've changed
this to pass the template format in to the digestor.
I've introduced a new instance variable that will be alive during a
template render. When the template is being rendered, it pushes the
current template on to a stack, setting `@current_template` to the
template currently being rendered. When the cache helper asks the
digestor for a key, it uses the format of the template currently on the
stack.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Currently `csp_meta_tag` generates `name` attribute only.
However, in libraries like `Material-UI` and `JSS`, expect that the meta tag
that contains the nonce with `property` attribute.
https://material-ui.com/css-in-js/advanced/#how-does-one-implement-csp
https://github.com/cssinjs/jss/blob/master/docs/csp.md
This patch allows `csp_meta_tag` to specify arbitrary options and
allows `nonce` to be passed to those libraries.
|
|/
|
|
|
|
|
|
|
|
|
| |
This commit keeps a stack of lookup contexts on the ActionView::Base
instance. If a format is passed to render, we instantiate a new lookup
context and push it on the stack, that way any child calls to "render"
will use the same format information as the parent. This also isolates
"sibling" calls to render (multiple calls to render in the same
template).
Fixes #35222 #34138
|
|\
| |
| |
| | |
Closes #34975.
|
| | |
|
| |
| |
| |
| |
| |
| | |
- Use `\z` instead of `$`
- Use character class instead of alternation
- Optimize alternation order
|
|/
|
|
| |
Don't upsize images smaller than the specified dimensions.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The `#csrf_meta_tags` and `#token_tag` Action View helper methods are
expecting the class in which are included to explicitly define the
method `#protect_against_forgery?` or else they will fail with
`NoMethodError`.
This is a problem if you want to use Action View outside of Rails
applications. For example, in #34788 I used the `#button_to` helper
inside of the error pages templates that have a custom
`ActionView::Base` subclass, which did not defined
`#protect_against_forgery?` and trying to call the button failed.
I had to dig inside of Action View to find-out what's was going on. I
think we should either set a default method implementation in the
helpers or check for the method definition, but don't explicitly require
the presence of `#protect_against_forgery?` in every `ActionViews::Base`
subclass as the errors are hard to figure out.
|
|
|
|
|
|
|
|
| |
Because method arguments are different in the methods provided by form
helpers and form builders, I think these are necessary to prevent
confusion.
Fixes #34787
|
|
|
|
|
| |
* Fix integer regex deprecation warnings for Ruby 2.6.0
* Define =~ in FakeZone to avoid warnings from Ruby 2.6.0
|
|
|
|
| |
side of long lines; Fixes #34487
|
|
|
|
|
|
|
|
|
|
|
| |
The usage of maxlength in the text_field helper adds a size attribute
to the generated text_field input with the same value as the maxlength.
This implicit addition of size attribute by the method gives a false
impression that it may be bug. By adding the implementation of the
maxlength to the api docs, we explicitly tell the reader referring the
api doc that addition of size along with maxlength is the expected behaviour.
[ci skip]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since Rails 6.0 will support Ruby 2.4.1 or higher
`# frozen_string_literal: true` magic comment is enough to make string object frozen.
This magic comment is enabled by `Style/FrozenStringLiteralComment` cop.
* Exclude these files not to auto correct false positive `Regexp#freeze`
- 'actionpack/lib/action_dispatch/journey/router/utils.rb'
- 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb'
It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333
Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed.
* Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required
- 'actionpack/test/controller/test_case_test.rb'
- 'activemodel/test/cases/type/string_test.rb'
- 'activesupport/lib/active_support/core_ext/string/strip.rb'
- 'activesupport/test/core_ext/string_ext_test.rb'
- 'railties/test/generators/actions_test.rb'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`.
```ruby
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "benchmark-ips"
end
Benchmark.ips do |x|
x.report('+@') { +"" }
x.report('dup') { "".dup }
x.compare!
end
```
```
$ ruby -v benchmark.rb
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
Warming up --------------------------------------
+@ 282.289k i/100ms
dup 187.638k i/100ms
Calculating -------------------------------------
+@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s
dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s
Comparison:
+@: 6775299.3 i/s
dup: 3320400.7 i/s - 2.04x slower
```
|
|\
| |
| | |
Let escape_javascript handle conversion to string
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This brings `escape_javascript` in line with the behavior of `json_escape` and
allows other value types to be output without needing explicit casting in the
view template.
Example:
<%= javascript_tag do %>
var locale = '<%== j I18n.locale %>'; // locale is a symbol
<% end %>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
On every iteration of generating a cache for a collection a “digest path” is calculated even though it’s exactly the same for every element.
This PR exposes a method `digest_path_from_virtual` that returns back a “digest_path”. This can in turn be passed back into `cache_fragment_name`. This not only does less work, but it also (you guessed it) uses less memory.
before: Total allocated: 762539 bytes (7035 objects)
after: Total allocated: 743590 bytes (6621 objects)
(762539 - 743590)/ 762539.0 # => 2.4% faster ⚡️⚡️
|
| | |
|
| | |
|
|\ \
| | |
| | | |
Finish converting whitelist and blacklist references
|
| | | |
|
| | | |
|
|/ / |
|
|\ \
| | |
| | |
| | | |
Use public_send in value_for_collection
|
| | |
| | |
| | |
| | |
| | | |
Instead of dropping it completely in case someone is relying (probably
inadvertenly) on it.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Avoid exposing private methods in view's helpers. However, as
`extract_values_from_collection` is only called from
`options_from_collection_for_select` where `value_for_collection` is
previously called, this case was already covered. The change makes
anyway sense for consistency and in case the code changes in the
future.
|
| |/
| |
| |
| |
| |
| | |
Avoid exposing private methods in view's helpers.
Fixes https://github.com/rails/rails/issues/33546
|
|\ \
| | |
| | |
| | |
| | |
| | |
| | | |
emaxi/feature/add-missing-documentation-option-to-number-to-currency
Add missing documentation option to number_to_currency
[ci skip]
|
| | | |
|
| | |
| | |
| | |
| | | |
To prevent style check in review like https://github.com/rails/rails/pull/33608#discussion_r211087605.
|
| |/
|/| |
|
| |
| |
| |
| |
| | |
This commit follows the path we started at commit #ea4f0e2
and continued at PR #33229.
|
| |
| |
| |
| |
| | |
In cases where the MatchData object is not used, this provides a speed-up:
https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
|
|\ \
| | |
| | | |
Keep time_tag docs up-to-date.
|
| | |
| | |
| | |
| | |
| | | |
The pubdate attribute was removed from the spec, see
940eec417f20e53abd3e3114c7fa845dac0d3a62 for context.
|