aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/tags/base.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fixes grammar in comments on tag_name and tag_idMichael Bock2019-04-251-2/+2
|
* Ruby 2.4 and later support native Unicode case mappingsRyuta Kamizono2019-03-181-1/+1
| | | | Here is only place where we use `mb_chars` internally.
* Fix unique DOM IDs for collection inputsMark Edmondson2019-01-251-1/+1
|
* Interpolate '' instead of nil when multiple is false.Dillon Welch2018-03-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "my string #{nil}" results in an additional '' string allocation, I'm guessing because the nil has to be converted to a string. "my string #{'[]' if multiple}" results in "my string #{nil}" if multiple is false. Doing "my string #{''}" does not result in an extra string allocation. I moved the if multiple logic into a method so I only had to make the change once. ```ruby begin require "bundler/inline" rescue LoadError => e $stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" raise e end gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" gem "rails" end def allocate_count GC.disable before = ObjectSpace.count_objects yield after = ObjectSpace.count_objects after.each { |k,v| after[k] = v - before[k] } after[:T_HASH] -= 1 # probe effect - we created the before hash. GC.enable result = after.reject { |k,v| v == 0 } GC.start result end @html_options = {} def master_version(multiple=nil) "hi#{"[]" if multiple}" end def fast_version(multiple=nil) str = multiple ? "[]" : '' "hi#{str}" end def test puts "master_version" puts allocate_count { 1000.times { master_version } } puts "master_version with arg" puts allocate_count { 1000.times { master_version(' there') } } puts "fast_version" puts allocate_count { 1000.times { fast_version } } puts "fast_version with arg" puts allocate_count { 1000.times { fast_version(' there') } } Benchmark.ips do |x| x.report("master_version") { master_version } x.report("master_version with arg") { master_version(' there') } x.report("fast_version") { fast_version } x.report("fast_version with arg") { fast_version(' there') } x.compare! end end test ``` results: ```ruby master_version {:FREE=>-1981, :T_STRING=>2052} master_version with arg {:FREE=>-1001, :T_STRING=>1000} fast_version {:FREE=>-1001, :T_STRING=>1000} fast_version with arg {:FREE=>-1001, :T_STRING=>1000} Warming up -------------------------------------- master_version 138.851k i/100ms master_version with arg 164.029k i/100ms fast_version 165.737k i/100ms fast_version with arg 167.016k i/100ms Calculating ------------------------------------- master_version 2.464M (±14.7%) i/s - 11.941M in 5.023307s master_version with arg 3.754M (± 8.5%) i/s - 18.699M in 5.021354s fast_version 3.449M (±11.7%) i/s - 17.071M in 5.033312s fast_version with arg 3.636M (± 6.9%) i/s - 18.205M in 5.034792s Comparison: master_version with arg: 3753896.1 i/s fast_version with arg: 3636094.5 i/s - same-ish: difference falls within error fast_version: 3448766.2 i/s - same-ish: difference falls within error master_version: 2463857.3 i/s - 1.52x slower ```
* Let select render default selected option for required fieldSerj Prikhodko2018-02-271-1/+5
|
* Make sure that form_with_generates_ids only affects form_withRafael Mendonça França2017-11-251-1/+2
|
* Change `form_with` to generates ids by defaultnpezza932017-11-251-4/+3
| | | | | | | | | | When `form_with` was introduced we disabled the automatic generation of ids that was enabled in `form_for`. This usually is not an good idea since labels don't work when the input doesn't have an id and it made harder to test with Capybara. You can still disable the automatic generation of ids setting `config.action_view.form_with_generates_ids` to `false.`
* Merge pull request #29791 from yui-knk/at_objectRyuta Kamizono2017-09-051-6/+6
|\ | | | | Do not pass an instance variable to a private method
| * Do not pass an instance variable to a private methodyui-knk2017-09-051-6/+6
| | | | | | | | | | | | | | | | | | | | | | `ActionView::Helpers::Tags::Base` has `@object` and all passed arguments for * `#value` * `#value_before_type_cast` * `#value_came_from_user?` are `@object`, so we do not need to pass arguments in this case.
* | Allow non-English values for collection_radio_buttons/check_boxescolorfulfool2017-08-021-1/+1
| |
* | Use frozen string literal in actionview/Kir Shatrov2017-07-241-0/+2
|/
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Move slicing to initializer.Kasper Timm Hansen2017-06-071-1/+1
| | | | | | Forgot all about https://github.com/rails/rails/pull/28844/files#r113780934 cc @rafaelfranca
* Remove unnecessary `skip_default_ids` and ↵kyuden2017-04-241-1/+1
| | | | `allow_method_names_outside_object` attributes of select tag in `form_with`
* Generate indexed names in input even when objects are not persistedRafael Mendonça França2017-01-031-2/+13
| | | | | | | | | | | | | | When you ask to generate multiple nested inputs using: field_for('comments[]', Comment.new) do |c| c.text_field :body Rails should generated the names like `post[comments][][body]`. To make sure we don't have regression the fake models now use the same implementation of `#to_param` as `ActiveRecord::Base` Fixes #26942
* form_with: allow methods outside the model.Kasper Timm Hansen2016-12-181-3/+14
| | | | | | | | Has the handy effect of making the initial examples in the form_with docs work too. Had to do some finagling such that form_with's without a scope didn't wrap their names in braces ala `[title]`.
* form_with/fields: Don't output ids by defaultKasper Timm Hansen2016-12-131-3/+11
| | | | | | | | | | | Continuing 67f81cc where we decided not to output ids by default in the new form helpers. Went with @dhh's suggestion of just requiring ids on fields being labelled: https://github.com/rails/rails/issues/25197#issuecomment-231797117 Seems okay enough.
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-3/+3
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-2/+2
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-99/+99
|
* modernizes hash syntax in actionviewXavier Noria2016-08-061-3/+3
|
* applies new string literal convention in actionview/libXavier Noria2016-08-061-3/+3
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* New syntax for tag helpers i.e. tag.br instead of tag(br) #25195Marek2016-06-271-2/+2
|
* Raise an ArgumentError when `include_blank` is false for a required field inGrey Baker2015-06-081-3/+9
| | | | | | | | | | `Tags::Base#select_content_tag`. Previously, passing a falsey value to `include_blank` would be ignored if the field was required, and a blank line would still be inserted. The following will now raise instead of quietly failing: `select("post", "category", %w(a required field), { include_blank: false }, required: 'required')`
* Remove code duplication in ActionView::Helpers::Tags::BaseBogdan Gusiev2015-02-111-25/+24
|
* Only use the `_before_type_cast` in the form when from user inputSean Griffin2015-01-141-2/+9
| | | | | | While we don't want to change the form input when validations fail, blindly using `_before_type_cast` will cause the input to display the wrong data for any type which does additional work on database values.
* Revert "Don't use the `_before_type_cast` version of attributes in the form"Sean Griffin2015-01-141-0/+10
| | | | This reverts commit 787e22bb491bd8c36db1e9734261c4ce02c5c5fd.
* Don't use the `_before_type_cast` version of attributes in the formSean Griffin2015-01-141-10/+0
| | | | | | | | | | | We should never be ignoring valuable information that the types may need to give us. The reason that it originally used `_before_type_cast` is unclear, but appears to date back long enough that the reasons may not be relevant today. There is only one test that asserts that it uses the before type cast version, but it gives no context as to why and uses a mock which does not simulate the real world. Fixes #18523.
* Honor public/private in ActionView::Helpers::Tags::Base#valueTobias Pfeiffer2014-10-311-1/+1
| | | | | * use public_send instead of send to avoid calling private methods in form helpers
* Fix some edge cases for AV `select` helper with `:selected` optionBogdan Gusiev2013-09-231-1/+2
|
* Move actionpack/lib/action_view* into actionview/libPiotr Sarnacki2013-06-201-0/+147