Skip to content
This repository
Browse code

Use 1.9 hash style on code and docs.

  • Loading branch information...
commit 34312c9fbc00ceb918c55d2ca7d36e3b94be301c 1 parent e206a53
Renato Mascarenhas rmascarenhas authored

Showing 55 changed files with 792 additions and 792 deletions. Show diff stats Hide diff stats

  1. +1 1  CHANGELOG.md
  2. +64 64 README.md
  3. +1 1  Rakefile
  4. +3 3 lib/generators/simple_form/install_generator.rb
  5. +1 1  lib/generators/simple_form/templates/README
  6. +8 8 lib/generators/simple_form/templates/config/initializers/simple_form.rb
  7. +14 14 lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb
  8. +3 3 lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb
  9. +6 6 lib/simple_form.rb
  10. +1 1  lib/simple_form/action_view_extensions/form_helper.rb
  11. +1 1  lib/simple_form/components.rb
  12. +1 1  lib/simple_form/components/html5.rb
  13. +3 3 lib/simple_form/components/labels.rb
  14. +2 2 lib/simple_form/error_notification.rb
  15. +33 33 lib/simple_form/form_builder.rb
  16. +1 1  lib/simple_form/helpers.rb
  17. +2 2 lib/simple_form/inputs/base.rb
  18. +1 1  lib/simple_form/inputs/block_input.rb
  19. +1 1  lib/simple_form/inputs/boolean_input.rb
  20. +6 6 lib/simple_form/inputs/collection_input.rb
  21. +4 4 lib/simple_form/tags.rb
  22. +1 1  lib/simple_form/wrappers.rb
  23. +5 5 lib/simple_form/wrappers/builder.rb
  24. +63 63 test/action_view_extensions/builder_test.rb
  25. +12 12 test/action_view_extensions/form_helper_test.rb
  26. +46 46 test/components/label_test.rb
  27. +22 22 test/form_builder/association_test.rb
  28. +4 4 test/form_builder/button_test.rb
  29. +8 8 test/form_builder/error_notification_test.rb
  30. +12 12 test/form_builder/error_test.rb
  31. +43 43 test/form_builder/general_test.rb
  32. +22 22 test/form_builder/hint_test.rb
  33. +6 6 test/form_builder/input_field_test.rb
  34. +6 6 test/form_builder/label_test.rb
  35. +21 21 test/form_builder/wrapper_test.rb
  36. +23 23 test/inputs/boolean_input_test.rb
  37. +55 55 test/inputs/collection_check_boxes_input_test.rb
  38. +70 70 test/inputs/collection_radio_buttons_input_test.rb
  39. +45 45 test/inputs/collection_select_input_test.rb
  40. +11 11 test/inputs/datetime_input_test.rb
  41. +10 10 test/inputs/disabled_test.rb
  42. +4 4 test/inputs/discovery_test.rb
  43. +1 1  test/inputs/file_input_test.rb
  44. +12 12 test/inputs/general_test.rb
  45. +20 20 test/inputs/grouped_collection_select_input_test.rb
  46. +1 1  test/inputs/hidden_input_test.rb
  47. +3 3 test/inputs/numeric_input_test.rb
  48. +3 3 test/inputs/priority_input_test.rb
  49. +12 12 test/inputs/readonly_test.rb
  50. +5 5 test/inputs/required_test.rb
  51. +8 8 test/inputs/string_input_test.rb
  52. +1 1  test/inputs/text_input_test.rb
  53. +24 24 test/support/misc_helpers.rb
  54. +37 37 test/support/models.rb
  55. +19 19 test/test_helper.rb
2  CHANGELOG.md
Source Rendered
@@ -117,7 +117,7 @@
117 117 * Generate configuration file with `browser_validations` disabled.
118 118 * Add option and configuration to specify the collection wrapper class. ([@mfila](https://github.com/mfila))
119 119 * Add proc support to `collection` option. ([@jeffkreeftmeijer](https://github.com/jeffkreeftmeijer))
120   - * `simple_form_for` allows default options for its inputs `:defaults => {}`.
  120 + * `simple_form_for` allows default options for its inputs `defaults: {}`.
121 121 * Add `readonly` as option of input method. ([@Untainted123](https://github.com/Untainted123))
122 122 * `simple_fields_for` for inherits wrapper option form the form builder. ([@nashby](https://github.com/nashby))
123 123 * Use action prefix in the form css class. Closes [#360](https://github.com/plataformatec/simple_form/issues/360).
128 README.md
Source Rendered
@@ -95,10 +95,10 @@ even a placeholder. For boolean inputs, you can add an inline label as well:
95 95
96 96 ```erb
97 97 <%= simple_form_for @user do |f| %>
98   - <%= f.input :username, :label => 'Your username please' %>
99   - <%= f.input :password, :hint => 'No special characters.' %>
100   - <%= f.input :email, :placeholder => 'user@domain.com' %>
101   - <%= f.input :remember_me, :inline_label => 'Yes, remember me' %>
  98 + <%= f.input :username, label: 'Your username please' %>
  99 + <%= f.input :password, hint: 'No special characters.' %>
  100 + <%= f.input :email, placeholder: 'user@domain.com' %>
  101 + <%= f.input :remember_me, inline_label: 'Yes, remember me' %>
102 102 <%= f.button :submit %>
103 103 <% end %>
104 104 ```
@@ -108,9 +108,9 @@ of any of them:
108 108
109 109 ```erb
110 110 <%= simple_form_for @user do |f| %>
111   - <%= f.input :username, :label_html => { :class => 'my_class' } %>
112   - <%= f.input :password, :hint => false, :error_html => { :id => 'password_error'} %>
113   - <%= f.input :password_confirmation, :label => false %>
  111 + <%= f.input :username, label_html: { class: 'my_class' } %>
  112 + <%= f.input :password, hint: false, error_html: { id: 'password_error'} %>
  113 + <%= f.input :password_confirmation, label: false %>
114 114 <%= f.button :submit %>
115 115 <% end %>
116 116 ```
@@ -120,9 +120,9 @@ option, for instance:
120 120
121 121 ```erb
122 122 <%= simple_form_for @user do |f| %>
123   - <%= f.input :username, :input_html => { :class => 'special' } %>
124   - <%= f.input :password, :input_html => { :maxlength => 20 } %>
125   - <%= f.input :remember_me, :input_html => { :value => '1' } %>
  123 + <%= f.input :username, input_html: { class: 'special' } %>
  124 + <%= f.input :password, input_html: { maxlength: 20 } %>
  125 + <%= f.input :remember_me, input_html: { value: '1' } %>
126 126 <%= f.button :submit %>
127 127 <% end %>
128 128 ```
@@ -132,10 +132,10 @@ you can use the `:defaults` option in `simple_form_for`. Specific options in `in
132 132 overwrite the defaults:
133 133
134 134 ```erb
135   -<%= simple_form_for @user, :defaults => { :input_html => { :class => 'default_class' } } do |f| %>
136   - <%= f.input :username, :input_html => { :class => 'special' } %>
137   - <%= f.input :password, :input_html => { :maxlength => 20 } %>
138   - <%= f.input :remember_me, :input_html => { :value => '1' } %>
  135 +<%= simple_form_for @user, defaults: { input_html: { class: 'default_class' } } do |f| %>
  136 + <%= f.input :username, input_html: { class: 'special' } %>
  137 + <%= f.input :password, input_html: { maxlength: 20 } %>
  138 + <%= f.input :remember_me, input_html: { value: '1' } %>
139 139 <%= f.button :submit %>
140 140 <% end %>
141 141 ```
@@ -145,9 +145,9 @@ any html attribute to that wrapper as well using the `:wrapper_html` option, lik
145 145
146 146 ```erb
147 147 <%= simple_form_for @user do |f| %>
148   - <%= f.input :username, :wrapper_html => { :class => 'username' } %>
149   - <%= f.input :password, :wrapper_html => { :id => 'password' } %>
150   - <%= f.input :remember_me, :wrapper_html => { :class => 'options' } %>
  148 + <%= f.input :username, wrapper_html: { class: 'username' } %>
  149 + <%= f.input :password, wrapper_html: { id: 'password' } %>
  150 + <%= f.input :remember_me, wrapper_html: { class: 'options' } %>
151 151 <%= f.button :submit %>
152 152 <% end %>
153 153 ```
@@ -160,7 +160,7 @@ And of course, the `required` property of any input can be overwritten as needed
160 160
161 161 ```erb
162 162 <%= simple_form_for @user do |f| %>
163   - <%= f.input :name, :required => false %>
  163 + <%= f.input :name, required: false %>
164 164 <%= f.input :username %>
165 165 <%= f.input :password %>
166 166 <%= f.button :submit %>
@@ -173,15 +173,15 @@ And of course, the `required` property of any input can be overwritten as needed
173 173 <%= simple_form_for @user do |f| %>
174 174 <%= f.input :username %>
175 175 <%= f.input :password %>
176   - <%= f.input :description, :as => :text %>
177   - <%= f.input :accepts, :as => :radio_buttons %>
  176 + <%= f.input :description, as: :text %>
  177 + <%= f.input :accepts, as: :radio_buttons %>
178 178 <%= f.button :submit %>
179 179 <% end %>
180 180 ```
181 181
182 182 So instead of a checkbox for the *accepts* attribute, you'll have a pair of radio buttons with yes/no
183 183 labels and a text area instead of a text field for the description. You can also render boolean
184   -attributes using `:as => :select` to show a dropdown.
  184 +attributes using `as: :select` to show a dropdown.
185 185
186 186 It is also possible to give the `:disabled` option to **SimpleForm**, and it'll automatically mark
187 187 the wrapper as disabled with a css class, so you can style labels, hints and other components inside
@@ -189,7 +189,7 @@ the wrapper as well:
189 189
190 190 ```erb
191 191 <%= simple_form_for @user do |f| %>
192   - <%= f.input :username, :disabled => true, :hint => 'You cannot change your username.' %>
  192 + <%= f.input :username, disabled: true, hint: 'You cannot change your username.' %>
193 193 <%= f.button :submit %>
194 194 <% end %>
195 195 ```
@@ -198,9 +198,9 @@ the wrapper as well:
198 198
199 199 ```erb
200 200 <%= simple_form_for @user do |f| %>
201   - <%= f.input :date_of_birth, :as => :date, :start_year => Date.today.year - 90,
202   - :end_year => Date.today.year - 12, :discard_day => true,
203   - :order => [:month, :year] %>
  201 + <%= f.input :date_of_birth, as: :date, start_year: Date.today.year - 90,
  202 + end_year: Date.today.year - 12, discard_day: true,
  203 + order: [:month, :year] %>
204 204 <%= f.button :submit %>
205 205 <% end %>
206 206 ```
@@ -213,7 +213,7 @@ the wrapper as well:
213 213 <%= f.label :username %>
214 214 <%= f.input_field :username %>
215 215 <%= f.hint 'No special characters, please!' %>
216   - <%= f.error :username, :id => 'user_name_error' %>
  216 + <%= f.error :username, id: 'user_name_error' %>
217 217 <%= f.full_error :token %>
218 218 <%= f.submit 'Save' %>
219 219 <% end %>
@@ -229,13 +229,13 @@ overriding the `:collection` option:
229 229 ```erb
230 230 <%= simple_form_for @user do |f| %>
231 231 <%= f.input :user %>
232   - <%= f.input :age, :collection => 18..60 %>
  232 + <%= f.input :age, collection: 18..60 %>
233 233 <%= f.button :submit %>
234 234 <% end %>
235 235 ```
236 236
237 237 Collections can be arrays or ranges, and when a `:collection` is given the `:select` input will be
238   -rendered by default, so we don't need to pass the `:as => :select` option. Other types of collection
  238 +rendered by default, so we don't need to pass the `as: :select` option. Other types of collection
239 239 are `:radio_buttons` and `:check_boxes`. Those are added by **SimpleForm** to Rails set of form
240 240 helpers (read Extra Helpers session below for more information).
241 241
@@ -252,13 +252,13 @@ translation. All other options given are sent straight to the underlying helper.
252 252 can give prompt as:
253 253
254 254 ```ruby
255   -f.input :age, :collection => 18..60, :prompt => "Select your age"
  255 +f.input :age, collection: 18..60, prompt: "Select your age"
256 256 ```
257 257
258 258 It is also possible to create grouped collection selects, that will use the html *optgroup* tags, like this:
259 259
260 260 ```ruby
261   -f.input :country_id, :collection => @continents, :as => :grouped_select, :group_method => :countries
  261 +f.input :country_id, collection: @continents, as: :grouped_select, group_method: :countries
262 262 ```
263 263
264 264 Grouped collection inputs accept the same `:label_method` and `:value_method` options, which will be
@@ -277,8 +277,8 @@ used to retrieve label/value attributes for the `option` tags. Besides that, you
277 277 `:priority` as option to select which time zones and/or countries should be given higher priority:
278 278
279 279 ```ruby
280   -f.input :residence_country, :priority => [ "Brazil" ]
281   -f.input :time_zone, :priority => /US/
  280 +f.input :residence_country, priority: [ "Brazil" ]
  281 +f.input :time_zone, priority: /US/
282 282 ```
283 283
284 284 Those values can also be configured with a default value to be used site use through the
@@ -288,7 +288,7 @@ Note: While using `country_select` if you want to restrict to only a subset of c
288 288 drop down then you may use the `:collection` option:
289 289
290 290 ```ruby
291   -f.input :shipping_country, :priority => [ "Brazil" ], :collection => [ "Australia", "Brazil", "New Zealand"]
  291 +f.input :shipping_country, priority: [ "Brazil" ], collection: [ "Australia", "Brazil", "New Zealand"]
292 292 ```
293 293
294 294 ### Associations
@@ -328,8 +328,8 @@ Simple enough, right? This is going to render a `:select` input for choosing the
328 328 buttons and check boxes as well:
329 329
330 330 ```ruby
331   -f.association :company, :as => :radio_buttons
332   -f.association :roles, :as => :check_boxes
  331 +f.association :company, as: :radio_buttons
  332 +f.association :roles, as: :check_boxes
333 333 ```
334 334
335 335 The association helper just invokes `input` under the hood, so all options available to `:select`,
@@ -337,13 +337,13 @@ The association helper just invokes `input` under the hood, so all options avail
337 337 the collection by hand, all together with the prompt:
338 338
339 339 ```ruby
340   -f.association :company, :collection => Company.active.all(:order => 'name'), :prompt => "Choose a Company"
  340 +f.association :company, collection: Company.active.all(order: 'name'), prompt: "Choose a Company"
341 341 ```
342 342
343 343 In case you want to declare different labels and values:
344 344
345 345 ```ruby
346   -f.association :company, :label_method => :company_name, :value_method => :id, :include_blank => false
  346 +f.association :company, label_method: :company_name, value_method: :id, include_blank: false
347 347 ```
348 348
349 349 ### Buttons
@@ -366,7 +366,7 @@ calling input with a block like so:
366 366
367 367 ```erb
368 368 <%= f.input :role do %>
369   - <%= f.select :role, Role.all.map { |r| [r.name, r.id, { :class => r.company.id }] }, :include_blank => true %>
  369 + <%= f.select :role, Role.all.map { |r| [r.name, r.id, { class: r.company.id }] }, include_blank: true %>
370 370 <% end %>
371 371 ```
372 372
@@ -485,7 +485,7 @@ end
485 485 And use it in your views:
486 486
487 487 ```ruby
488   -f.input :money, :as => :currency
  488 +f.input :money, as: :currency
489 489 ```
490 490
491 491 You can also redefine existing **SimpleForm** inputs by creating a new class with the same name. For
@@ -520,7 +520,7 @@ Create a helper method that calls `simple_form_for` with a custom builder:
520 520 ```ruby
521 521 def custom_form_for(object, *args, &block)
522 522 options = args.extract_options!
523   - simple_form_for(object, *(args << options.merge(:builder => CustomFormBuilder)), &block)
  523 + simple_form_for(object, *(args << options.merge(builder: CustomFormBuilder)), &block)
524 524 end
525 525 ```
526 526
@@ -529,7 +529,7 @@ Create a form builder class that inherits from `SimpleForm::FormBuilder`.
529 529 ```ruby
530 530 class CustomFormBuilder < SimpleForm::FormBuilder
531 531 def input(attribute_name, options = {}, &block)
532   - options[:input_html].merge! :class => 'custom'
  532 + options[:input_html].merge! class: 'custom'
533 533 super
534 534 end
535 535 end
@@ -612,7 +612,7 @@ that would post either `male` or `female` as value. With **SimpleForm** you coul
612 612 like this:
613 613
614 614 ```ruby
615   -f.input :gender, :collection => [:male, :female]
  615 +f.input :gender, collection: [:male, :female]
616 616 ```
617 617
618 618 And **SimpleForm** will try a lookup like this in your locale file, to find the right labels to show:
@@ -674,7 +674,7 @@ en:
674 674 This difference exists because **SimpleForm** relies on `object_name` provided by Rails'
675 675 FormBuilder to determine the translation path for a given object instead of `i18n_key` from the
676 676 object itself. Thus, similarly, if a form for an `Admin::User` object is defined by calling
677   -`simple_form_for @admin_user, :as => :some_user`, **SimpleForm** will look for translations
  677 +`simple_form_for @admin_user, as: :some_user`, **SimpleForm** will look for translations
678 678 under `some_user` instead of `admin_user`.
679 679
680 680 ## Configuration
@@ -690,8 +690,8 @@ With **SimpleForm** you can configure how your components will be rendered using
690 690 The syntax looks like this:
691 691
692 692 ```ruby
693   -config.wrappers :tag => :div, :class => :input,
694   - :error_class => :field_with_errors do |b|
  693 +config.wrappers tag: :div, class: :input,
  694 + error_class: :field_with_errors do |b|
695 695
696 696 # Form extensions
697 697 b.use :html5
@@ -702,8 +702,8 @@ config.wrappers :tag => :div, :class => :input,
702 702
703 703 # Form components
704 704 b.use :label_input
705   - b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
706   - b.use :error, :wrap_with => { :tag => :span, :class => :error }
  705 + b.use :hint, wrap_with: { tag: :span, class: :hint }
  706 + b.use :error, wrap_with: { tag: :span, class: :error }
707 707 end
708 708 ```
709 709
@@ -726,9 +726,9 @@ You can create new _Form components_ using the wrappers API as in the following
726 726 config.wrappers do |b|
727 727 b.use :placeholder
728 728 b.use :label_input
729   - b.wrapper :tag => :div, :class => 'separator' do |component|
730   - component.use :hint, :wrap_with => { :tag => :span, :class => :hint }
731   - component.use :error, :wrap_with => { :tag => :span, :class => :error }
  729 + b.wrapper tag: :div, class: 'separator' do |component|
  730 + component.use :hint, wrap_with: { tag: :span, class: :hint }
  731 + component.use :error, wrap_with: { tag: :span, class: :error }
732 732 end
733 733 end
734 734 ```
@@ -741,9 +741,9 @@ If you want to customize the custom _Form components_ on demand you can give it
741 741 config.wrappers do |b|
742 742 b.use :placeholder
743 743 b.use :label_input
744   - b.wrapper :my_wrapper, :tag => :div, :class => 'separator' do |component|
745   - component.use :hint, :wrap_with => { :tag => :span, :class => :hint }
746   - component.use :error, :wrap_with => { :tag => :span, :class => :error }
  744 + b.wrapper :my_wrapper, tag: :div, class: 'separator' do |component|
  745 + component.use :hint, wrap_with: { tag: :span, class: :hint }
  746 + component.use :error, wrap_with: { tag: :span, class: :error }
747 747 end
748 748 end
749 749 ```
@@ -752,13 +752,13 @@ and now you can pass options to your `input` calls to customize the `:my_wrapper
752 752
753 753 ```ruby
754 754 # Completely turns off the custom wrapper
755   -f.input :name, :my_wrapper => false
  755 +f.input :name, my_wrapper: false
756 756
757 757 # Configure the html
758   -f.input :name, :my_wrapper_html => { :id => 'special_id' }
  758 +f.input :name, my_wrapper_html: { id: 'special_id' }
759 759
760 760 # Configure the tag
761   -f.input :name, :my_wrapper_tag => :p
  761 +f.input :name, my_wrapper_tag: :p
762 762 ```
763 763
764 764 You can also define more than one wrapper and pick one to render in a specific form or input.
@@ -775,13 +775,13 @@ and use it in this way:
775 775
776 776 ```ruby
777 777 # Specifying to whole form
778   -simple_form_for @user, :wrapper => :small do |f|
  778 +simple_form_for @user, wrapper: :small do |f|
779 779 f.input :name
780 780 end
781 781
782 782 # Specifying to one input
783 783 simple_form_for @user do |f|
784   - f.input :name, :wrapper => :small
  784 + f.input :name, wrapper: :small
785 785 end
786 786 ```
787 787
@@ -790,17 +790,17 @@ hints or placeholders, but you don't want them to be generated automatically. Yo
790 790 default values to `false` or use the `optional` method. Is preferible to use the `optional` syntax:
791 791
792 792 ```ruby
793   -config.wrappers :placeholder => false do |b|
  793 +config.wrappers placeholder: false do |b|
794 794 b.use :placeholder
795 795 b.use :label_input
796   - b.wrapper :tag => :div, :class => 'separator' do |component|
797   - component.optional :hint, :wrap_with => { :tag => :span, :class => :hint }
798   - component.use :error, :wrap_with => { :tag => :span, :class => :error }
  796 + b.wrapper tag: :div, class: 'separator' do |component|
  797 + component.optional :hint, wrap_with: { tag: :span, class: :hint }
  798 + component.use :error, wrap_with: { tag: :span, class: :error }
799 799 end
800 800 end
801 801 ```
802 802
803   -By setting it as `optional`, a hint will only be generated when `:hint => true` is explicitly used.
  803 +By setting it as `optional`, a hint will only be generated when `hint: true` is explicitly used.
804 804 The same for placehold.
805 805
806 806 ## HTML 5 Notice
@@ -835,7 +835,7 @@ help you to use some generic javascript validation.
835 835 You can also add `novalidate` to a specific form by setting the option on the form itself:
836 836
837 837 ```erb
838   -<%= simple_form_for(resource, :html => {:novalidate => true}) do |form| %>
  838 +<%= simple_form_for(resource, html: {novalidate: true}) do |form| %>
839 839 ```
840 840
841 841 Please notice that any of the configurations above will disable the `placeholder` component,
2  Rakefile
@@ -7,7 +7,7 @@ require 'rake/testtask'
7 7 require 'rdoc/task'
8 8
9 9 desc 'Default: run unit tests.'
10   -task :default => :test
  10 +task default: :test
11 11
12 12 desc 'Test the simple_form plugin.'
13 13 Rake::TestTask.new(:test) do |t|
6 lib/generators/simple_form/install_generator.rb
@@ -3,9 +3,9 @@ module Generators
3 3 class InstallGenerator < Rails::Generators::Base
4 4 desc "Copy SimpleForm default files"
5 5 source_root File.expand_path('../templates', __FILE__)
6   - class_option :template_engine, :desc => 'Template engine to be invoked (erb, haml or slim).'
7   - class_option :bootstrap, :type => :boolean, :desc => 'Add the Twitter Bootstrap wrappers to the SimpleForm initializer.'
8   - class_option :foundation, :type => :boolean, :desc => 'Add the Zurb Foundation 3 wrappers to the SimpleForm initializer.'
  6 + class_option :template_engine, desc: 'Template engine to be invoked (erb, haml or slim).'
  7 + class_option :bootstrap, type: :boolean, desc: 'Add the Twitter Bootstrap wrappers to the SimpleForm initializer.'
  8 + class_option :foundation, type: :boolean, desc: 'Add the Zurb Foundation 3 wrappers to the SimpleForm initializer.'
9 9
10 10 def info_bootstrap
11 11 return if options.bootstrap? || options.foundation?
2  lib/generators/simple_form/templates/README
@@ -7,6 +7,6 @@
7 7 classes, '.form-horizontal', '.form-inline', '.form-search' or
8 8 '.form-vertical', as the following:
9 9
10   - = simple_form_for(@user, :html => {:class => 'form-horizontal' }) do |form|
  10 + = simple_form_for(@user, html: {class: 'form-horizontal' }) do |form|
11 11
12 12 ===============================================================================
16 lib/generators/simple_form/templates/config/initializers/simple_form.rb
@@ -5,8 +5,8 @@
5 5 # wrapper, change the order or even add your own to the
6 6 # stack. The options given below are used to wrap the
7 7 # whole input.
8   - config.wrappers :default, :class => :input,
9   - :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
  8 + config.wrappers :default, class: :input,
  9 + hint_class: :field_with_hint, error_class: :field_with_errors do |b|
10 10 ## Extensions enabled by default
11 11 # Any of these extensions can be disabled for a
12 12 # given input by passing: `f.input EXTENSION_NAME => false`.
@@ -18,7 +18,7 @@
18 18 b.use :html5
19 19
20 20 # Calculates placeholders automatically from I18n
21   - # You can also pass a string as f.input :placeholder => "Placeholder"
  21 + # You can also pass a string as f.input placeholder: "Placeholder"
22 22 b.use :placeholder
23 23
24 24 ## Optional extensions
@@ -41,8 +41,8 @@
41 41
42 42 ## Inputs
43 43 b.use :label_input
44   - b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
45   - b.use :error, :wrap_with => { :tag => :span, :class => :error }
  44 + b.use :hint, wrap_with: { tag: :span, class: :hint }
  45 + b.use :error, wrap_with: { tag: :span, class: :error }
46 46 end
47 47
48 48 # The default wrapper to be used by the FormBuilder.
@@ -50,8 +50,8 @@
50 50
51 51 # Define the way to render check boxes / radio buttons with labels.
52 52 # Defaults to :nested for bootstrap config.
53   - # :inline => input + label
54   - # :nested => label > input
  53 + # inline: input + label
  54 + # nested: label > input
55 55 config.boolean_style = :nested
56 56
57 57 # Default class for buttons
@@ -120,7 +120,7 @@
120 120
121 121 # Custom wrappers for input types. This should be a hash containing an input
122 122 # type as key and the wrapper that will be used for all inputs with specified type.
123   - # config.wrapper_mappings = { :string => :prepend }
  123 + # config.wrapper_mappings = { string: :prepend }
124 124
125 125 # Default priority for time_zone inputs.
126 126 # config.time_zone_priority = nil
28 lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb
... ... @@ -1,39 +1,39 @@
1 1 # Use this setup block to configure all options available in SimpleForm.
2 2 SimpleForm.setup do |config|
3   - config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
  3 + config.wrappers :bootstrap, tag: 'div', class: 'control-group', error_class: 'error' do |b|
4 4 b.use :html5
5 5 b.use :placeholder
6 6 b.use :label
7   - b.wrapper :tag => 'div', :class => 'controls' do |ba|
  7 + b.wrapper tag: 'div', class: 'controls' do |ba|
8 8 ba.use :input
9   - ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
10   - ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
  9 + ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
  10 + ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
11 11 end
12 12 end
13 13
14   - config.wrappers :prepend, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
  14 + config.wrappers :prepend, tag: 'div', class: "control-group", error_class: 'error' do |b|
15 15 b.use :html5
16 16 b.use :placeholder
17 17 b.use :label
18   - b.wrapper :tag => 'div', :class => 'controls' do |input|
19   - input.wrapper :tag => 'div', :class => 'input-prepend' do |prepend|
  18 + b.wrapper tag: 'div', class: 'controls' do |input|
  19 + input.wrapper tag: 'div', class: 'input-prepend' do |prepend|
20 20 prepend.use :input
21 21 end
22   - input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
23   - input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
  22 + input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
  23 + input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
24 24 end
25 25 end
26 26
27   - config.wrappers :append, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
  27 + config.wrappers :append, tag: 'div', class: "control-group", error_class: 'error' do |b|
28 28 b.use :html5
29 29 b.use :placeholder
30 30 b.use :label
31   - b.wrapper :tag => 'div', :class => 'controls' do |input|
32   - input.wrapper :tag => 'div', :class => 'input-append' do |append|
  31 + b.wrapper tag: 'div', class: 'controls' do |input|
  32 + input.wrapper tag: 'div', class: 'input-append' do |append|
33 33 append.use :input
34 34 end
35   - input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
36   - input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
  35 + input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
  36 + input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
37 37 end
38 38 end
39 39
6 lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb
... ... @@ -1,6 +1,6 @@
1 1 # Use this setup block to configure all options available in SimpleForm.
2 2 SimpleForm.setup do |config|
3   - config.wrappers :foundation, :class => :input, :hint_class => :field_with_hint, :error_class => :error do |b|
  3 + config.wrappers :foundation, class: :input, hint_class: :field_with_hint, error_class: :error do |b|
4 4 b.use :html5
5 5 b.use :placeholder
6 6 b.optional :maxlength
@@ -8,11 +8,11 @@
8 8 b.optional :min_max
9 9 b.optional :readonly
10 10 b.use :label_input
11   - b.use :error, :wrap_with => { :tag => :small }
  11 + b.use :error, wrap_with: { tag: :small }
12 12
13 13 # Uncomment the following line to enable hints. The line is commented out by default since Foundation
14 14 # does't provide styles for hints. You will need to provide your own CSS styles for hints.
15   - # b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
  15 + # b.use :hint, wrap_with: { tag: :span, class: :hint }
16 16 end
17 17
18 18 # CSS class for buttons
12 lib/simple_form.rb
@@ -73,8 +73,8 @@ def self.eager_load!
73 73 @@label_class = nil
74 74
75 75 # Define the way to render check boxes / radio buttons with labels.
76   - # :inline => input + label (default)
77   - # :nested => label > input
  76 + # inline: input + label (default)
  77 + # nested: label > input
78 78 mattr_accessor :boolean_style
79 79 @@boolean_style = :inline
80 80
@@ -106,7 +106,7 @@ def self.eager_load!
106 106
107 107 # Custom wrappers for input types. This should be a hash containing an input
108 108 # type as key and the wrapper that will be used for all inputs with specified type.
109   - # e.g { :string => :string_wrapper, :boolean => :boolean_wrapper }
  109 + # e.g { string: :string_wrapper, boolean: :boolean_wrapper }
110 110 mattr_accessor :wrapper_mappings
111 111 @@wrapper_mappings = nil
112 112
@@ -174,7 +174,7 @@ def self.build(options={})
174 174 SimpleForm::Wrappers::Root.new(builder.to_a, options)
175 175 end
176 176
177   - wrappers :class => :input, :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
  177 + wrappers class: :input, hint_class: :field_with_hint, error_class: :field_with_errors do |b|
178 178 b.use :html5
179 179
180 180 b.use :min_max
@@ -184,8 +184,8 @@ def self.build(options={})
184 184 b.optional :readonly
185 185
186 186 b.use :label_input
187   - b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
188   - b.use :error, :wrap_with => { :tag => :span, :class => :error }
  187 + b.use :hint, wrap_with: { tag: :span, class: :hint }
  188 + b.use :error, wrap_with: { tag: :span, class: :error }
189 189 end
190 190
191 191 def self.additional_classes_for(component)
2  lib/simple_form/action_view_extensions/form_helper.rb
@@ -5,7 +5,7 @@ module ActionViewExtensions
5 5 # Example:
6 6 #
7 7 # simple_form_for @user do |f|
8   - # f.input :name, :hint => 'My hint'
  8 + # f.input :name, hint: 'My hint'
9 9 # end
10 10 #
11 11 module FormHelper
2  lib/simple_form/components.rb
@@ -2,7 +2,7 @@ module SimpleForm
2 2 # Components are a special type of helpers that can work on their own.
3 3 # For example, by using a component, it will automatically change the
4 4 # output under given circumstances without user input. For example,
5   - # the disabled helper always need a :disabled => true option given
  5 + # the disabled helper always need a disabled: true option given
6 6 # to the input in order to be enabled. On the other hand, things like
7 7 # hints can generate output automatically by doing I18n lookups.
8 8 module Components
2  lib/simple_form/components/html5.rb
@@ -23,4 +23,4 @@ def has_required?
23 23 end
24 24 end
25 25 end
26   -end
  26 +end
6 lib/simple_form/components/labels.rb
@@ -6,18 +6,18 @@ module Labels
6 6 module ClassMethods #:nodoc:
7 7 def translate_required_html
8 8 i18n_cache :translate_required_html do
9   - I18n.t(:"simple_form.required.html", :default =>
  9 + I18n.t(:"simple_form.required.html", default:
10 10 %[<abbr title="#{translate_required_text}">#{translate_required_mark}</abbr>]
11 11 )
12 12 end
13 13 end
14 14
15 15 def translate_required_text
16   - I18n.t(:"simple_form.required.text", :default => 'required')
  16 + I18n.t(:"simple_form.required.text", default: 'required')
17 17 end
18 18
19 19 def translate_required_mark
20   - I18n.t(:"simple_form.required.mark", :default => '*')
  20 + I18n.t(:"simple_form.required.mark", default: '*')
21 21 end
22 22 end
23 23
4 lib/simple_form/error_notification.rb
... ... @@ -1,6 +1,6 @@
1 1 module SimpleForm
2 2 class ErrorNotification
3   - delegate :object, :object_name, :template, :to => :@builder
  3 + delegate :object, :object_name, :template, to: :@builder
4 4
5 5 def initialize(builder, options)
6 6 @builder = builder
@@ -42,7 +42,7 @@ def translate_error_notification
42 42 lookups << :"#{object_name}"
43 43 lookups << :default_message
44 44 lookups << "Please review the problems below:"
45   - I18n.t(lookups.shift, :scope => :"simple_form.error_notification", :default => lookups)
  45 + I18n.t(lookups.shift, scope: :"simple_form.error_notification", default: lookups)
46 46 end
47 47 end
48 48 end
66 lib/simple_form/form_builder.rb
@@ -8,26 +8,26 @@ class FormBuilder < ActionView::Helpers::FormBuilder
8 8
9 9 # When action is create or update, we still should use new and edit
10 10 ACTIONS = {
11   - :create => :new,
12   - :update => :edit
  11 + create: :new,
  12 + update: :edit
13 13 }
14 14
15 15 extend MapType
16 16 include SimpleForm::Inputs
17 17
18   - map_type :text, :to => SimpleForm::Inputs::TextInput
19   - map_type :file, :to => SimpleForm::Inputs::FileInput
20   - map_type :string, :email, :search, :tel, :url, :to => SimpleForm::Inputs::StringInput
21   - map_type :password, :to => SimpleForm::Inputs::PasswordInput
22   - map_type :integer, :decimal, :float, :to => SimpleForm::Inputs::NumericInput
23   - map_type :range, :to => SimpleForm::Inputs::RangeInput
24   - map_type :check_boxes, :to => SimpleForm::Inputs::CollectionCheckBoxesInput
25   - map_type :radio_buttons, :to => SimpleForm::Inputs::CollectionRadioButtonsInput
26   - map_type :select, :to => SimpleForm::Inputs::CollectionSelectInput
27   - map_type :grouped_select, :to => SimpleForm::Inputs::GroupedCollectionSelectInput
28   - map_type :date, :time, :datetime, :to => SimpleForm::Inputs::DateTimeInput
29   - map_type :country, :time_zone, :to => SimpleForm::Inputs::PriorityInput
30   - map_type :boolean, :to => SimpleForm::Inputs::BooleanInput
  18 + map_type :text, to: SimpleForm::Inputs::TextInput
  19 + map_type :file, to: SimpleForm::Inputs::FileInput
  20 + map_type :string, :email, :search, :tel, :url, to: SimpleForm::Inputs::StringInput
  21 + map_type :password, to: SimpleForm::Inputs::PasswordInput
  22 + map_type :integer, :decimal, :float, to: SimpleForm::Inputs::NumericInput
  23 + map_type :range, to: SimpleForm::Inputs::RangeInput
  24 + map_type :check_boxes, to: SimpleForm::Inputs::CollectionCheckBoxesInput
  25 + map_type :radio_buttons, to: SimpleForm::Inputs::CollectionRadioButtonsInput
  26 + map_type :select, to: SimpleForm::Inputs::CollectionSelectInput
  27 + map_type :grouped_select, to: SimpleForm::Inputs::GroupedCollectionSelectInput
  28 + map_type :date, :time, :datetime, to: SimpleForm::Inputs::DateTimeInput
  29 + map_type :country, :time_zone, to: SimpleForm::Inputs::PriorityInput
  30 + map_type :boolean, to: SimpleForm::Inputs::BooleanInput
31 31
32 32 def self.discovery_cache
33 33 @discovery_cache ||= {}
@@ -49,7 +49,7 @@ def initialize(*) #:nodoc:
49 49 #
50 50 # # Imagine @user has error "can't be blank" on name
51 51 # simple_form_for @user do |f|
52   - # f.input :name, :hint => 'My hint'
  52 + # f.input :name, hint: 'My hint'
53 53 # end
54 54 #
55 55 # This is the output html (only the input portion, not the form):
@@ -67,15 +67,15 @@ def initialize(*) #:nodoc:
67 67 #
68 68 # You have some options for the input to enable/disable some functions:
69 69 #
70   - # :as => allows you to define the input type you want, for instance you
  70 + # as: allows you to define the input type you want, for instance you
71 71 # can use it to generate a text field for a date column.
72 72 #
73   - # :required => defines whether this attribute is required or not. True
  73 + # required: defines whether this attribute is required or not. True
74 74 # by default.
75 75 #
76 76 # The fact SimpleForm is built in components allow the interface to be unified.
77 77 # So, for instance, if you need to disable :hint for a given input, you can pass
78   - # :hint => false. The same works for :error, :label and :wrapper.
  78 + # hint: false. The same works for :error, :label and :wrapper.
79 79 #
80 80 # Besides the html for any component can be changed. So, if you want to change
81 81 # the label html you just need to give a hash to :label_html. To configure the
@@ -86,18 +86,18 @@ def initialize(*) #:nodoc:
86 86 # Some inputs, as datetime, time and select allow you to give extra options, like
87 87 # prompt and/or include blank. Such options are given in plainly:
88 88 #
89   - # f.input :created_at, :include_blank => true
  89 + # f.input :created_at, include_blank: true
90 90 #
91 91 # == Collection
92 92 #
93 93 # When playing with collections (:radio_buttons, :check_boxes and :select
94 94 # inputs), you have three extra options:
95 95 #
96   - # :collection => use to determine the collection to generate the radio or select
  96 + # collection: use to determine the collection to generate the radio or select
97 97 #
98   - # :label_method => the method to apply on the array collection to get the label
  98 + # label_method: the method to apply on the array collection to get the label
99 99 #
100   - # :value_method => the method to apply on the array collection to get the value
  100 + # value_method: the method to apply on the array collection to get the value
101 101 #
102 102 # == Priority
103 103 #
@@ -138,7 +138,7 @@ def input_field(attribute_name, options={})
138 138 options[:input_html] = options.except(:as, :collection, :label_method, :value_method)
139 139 options = @defaults.deep_dup.deep_merge(options) if @defaults
140 140
141   - SimpleForm::Wrappers::Root.new([:input], :wrapper => false).render find_input(attribute_name, options)
  141 + SimpleForm::Wrappers::Root.new([:input], wrapper: false).render find_input(attribute_name, options)
142 142 end
143 143
144 144 # Helper for dealing with association selects/radios, generating the
@@ -152,7 +152,7 @@ def input_field(attribute_name, options={})
152 152 # f.association :company # Company.all
153 153 # end
154 154 #
155   - # f.association :company, :collection => Company.all(:order => 'name')
  155 + # f.association :company, collection: Company.all(order: 'name')
156 156 # # Same as using :order option, but overriding collection
157 157 #
158 158 # == Block
@@ -203,7 +203,7 @@ def association(association, options={}, &block)
203 203 :"#{reflection.name.to_s.singularize}_ids"
204 204 end
205 205
206   - input(attribute, options.merge(:reflection => reflection))
  206 + input(attribute, options.merge(reflection: reflection))
207 207 end
208 208
209 209 # Creates a button:
@@ -234,7 +234,7 @@ def button(type, *args, &block)
234 234 # == Examples
235 235 #
236 236 # f.error :name
237   - # f.error :name, :id => "cool_error"
  237 + # f.error :name, id: "cool_error"
238 238 #
239 239 def error(attribute_name, options={})
240 240 options = options.dup
@@ -272,7 +272,7 @@ def full_error(attribute_name, options={})
272 272 # == Examples
273 273 #
274 274 # f.hint :name # Do I18n lookup
275   - # f.hint :name, :id => "cool_hint"
  275 + # f.hint :name, id: "cool_hint"
276 276 # f.hint "Don't forget to accept this"
277 277 #
278 278 def hint(attribute_name, options={})
@@ -299,10 +299,10 @@ def hint(attribute_name, options={})
299 299 #
300 300 # f.label :name # Do I18n lookup
301 301 # f.label :name, "Name" # Same behavior as Rails, do not add required tag
302   - # f.label :name, :label => "Name" # Same as above, but adds required tag
  302 + # f.label :name, label: "Name" # Same as above, but adds required tag
303 303 #
304   - # f.label :name, :required => false
305   - # f.label :name, :id => "cool_label"
  304 + # f.label :name, required: false
  305 + # f.label :name, id: "cool_label"
306 306 #
307 307 def label(attribute_name, *args)
308 308 return super if args.first.is_a?(String) || block_given?
@@ -323,8 +323,8 @@ def label(attribute_name, *args)
323 323 # == Examples
324 324 #
325 325 # f.error_notification
326   - # f.error_notification :message => 'Something went wrong'
327   - # f.error_notification :id => 'user_error_message', :class => 'form_error'
  326 + # f.error_notification message: 'Something went wrong'
  327 + # f.error_notification id: 'user_error_message', class: 'form_error'
328 328 #
329 329 def error_notification(options={})
330 330 SimpleForm::ErrorNotification.new(self, options).render
2  lib/simple_form/helpers.rb
... ... @@ -1,7 +1,7 @@
1 1 module SimpleForm
2 2 # Helpers are made of several helpers that cannot be turned on automatically.
3 3 # For instance, disabled cannot be turned on automatically, it requires the
4   - # user to explicitly pass the option :disabled => true so it may work.
  4 + # user to explicitly pass the option disabled: true so it may work.
5 5 module Helpers
6 6 autoload :Autofocus, 'simple_form/helpers/autofocus'
7 7 autoload :Disabled, 'simple_form/helpers/disabled'
4 lib/simple_form/inputs/base.rb
@@ -24,7 +24,7 @@ class Base
24 24 attr_reader :attribute_name, :column, :input_type, :reflection,
25 25 :options, :input_html_options, :input_html_classes, :html_classes
26 26
27   - delegate :template, :object, :object_name, :lookup_model_names, :lookup_action, :to => :@builder
  27 + delegate :template, :object, :object_name, :lookup_model_names, :lookup_action, to: :@builder
28 28
29 29 class_attribute :default_options
30 30 self.default_options = {}
@@ -175,7 +175,7 @@ def translate(namespace, default='')
175 175 lookups << :"defaults.#{reflection_or_attribute_name}"
176 176 lookups << default
177 177
178   - I18n.t(lookups.shift, :scope => :"simple_form.#{namespace}", :default => lookups).presence
  178 + I18n.t(lookups.shift, scope: :"simple_form.#{namespace}", default: lookups).presence
179 179 end
180 180 end
181 181 end
2  lib/simple_form/inputs/block_input.rb
@@ -11,4 +11,4 @@ def input
11 11 end
12 12 end
13 13 end
14   -end
  14 +end
2  lib/simple_form/inputs/boolean_input.rb
@@ -4,7 +4,7 @@ class BooleanInput < Base
4 4 def input
5 5 if nested_boolean_style?
6 6 build_hidden_field_for_checkbox +
7   - template.label_tag(nil, :class => "checkbox") {
  7 + template.label_tag(nil, class: "checkbox") {
8 8 build_check_box_without_hidden_field + inline_label
9 9 }
10 10 else
12 lib/simple_form/inputs/collection_input.rb
@@ -7,8 +7,8 @@ class CollectionInput < Base
7 7 # "simple_form.no" keys. See the example locale file.
8 8 def self.boolean_collection
9 9 i18n_cache :boolean_collection do
10   - [ [I18n.t(:"simple_form.yes", :default => 'Yes'), true],
11   - [I18n.t(:"simple_form.no", :default => 'No'), false] ]
  10 + [ [I18n.t(:"simple_form.yes", default: 'Yes'), true],
  11 + [I18n.t(:"simple_form.no", default: 'No'), false] ]
12 12 end
13 13 end
14 14
@@ -66,14 +66,14 @@ def detect_common_display_methods(collection_classes = detect_collection_classes
66 66 collection_translated = translate_collection if collection_classes == [Symbol]
67 67
68 68 if collection_translated || collection_classes.include?(Array)
69   - { :label => :first, :value => :last }
  69 + { label: :first, value: :last }
70 70 elsif collection_includes_basic_objects?(collection_classes)
71   - { :label => :to_s, :value => :to_s }
  71 + { label: :to_s, value: :to_s }
72 72 else
73 73 sample = collection.first || collection.last
74 74
75   - { :label => SimpleForm.collection_label_methods.find { |m| sample.respond_to?(m) },
76   - :value => SimpleForm.collection_value_methods.find { |m| sample.respond_to?(m) } }
  75 + { label: SimpleForm.collection_label_methods.find { |m| sample.respond_to?(m) },
  76 + value: SimpleForm.collection_value_methods.find { |m| sample.respond_to?(m) } }
77 77 end
78 78 end
79 79
8 lib/simple_form/tags.rb
@@ -14,7 +14,7 @@ def render_collection
14 14
15 15 rendered_item = yield item, value, text, default_html_options
16 16
17   - item_wrapper_tag ? @template_object.content_tag(item_wrapper_tag, rendered_item, :class => item_wrapper_class) : rendered_item
  17 + item_wrapper_tag ? @template_object.content_tag(item_wrapper_tag, rendered_item, class: item_wrapper_class) : rendered_item
18 18 end.join.html_safe
19 19 end
20 20
@@ -23,7 +23,7 @@ def wrap_rendered_collection(collection)
23 23
24 24 if wrapper_tag
25 25 wrapper_class = @options[:collection_wrapper_class]
26   - @template_object.content_tag(wrapper_tag, collection, :class => wrapper_class)
  26 + @template_object.content_tag(wrapper_tag, collection, class: wrapper_class)
27 27 else
28 28 collection
29 29 end
@@ -40,7 +40,7 @@ def render
40 40 private
41 41
42 42 def render_component(builder)
43   - builder.radio_button + builder.label(:class => "collection_radio_buttons")
  43 + builder.radio_button + builder.label(class: "collection_radio_buttons")
44 44 end
45 45 end
46 46
@@ -54,7 +54,7 @@ def render
54 54 private
55 55
56 56 def render_component(builder)
57   - builder.check_box + builder.label(:class => "collection_check_boxes")
  57 + builder.check_box + builder.label(class: "collection_check_boxes")
58 58 end
59 59 end
60 60 end
2  lib/simple_form/wrappers.rb
@@ -5,4 +5,4 @@ module Wrappers
5 5 autoload :Root, 'simple_form/wrappers/root'
6 6 autoload :Single, 'simple_form/wrappers/single'
7 7 end
8   -end
  8 +end
10 lib/simple_form/wrappers/builder.rb
@@ -12,18 +12,18 @@ module Wrappers
12 12 # b.optional :placeholder
13 13 #
14 14 # # Use a component with specific wrapper options
15   - # b.use :error, :wrap_with => { :tag => "span", :class => "error" }
  15 + # b.use :error, wrap_with: { tag: "span", class: "error" }
16 16 #
17 17 # # Use a set of components by wrapping them in a tag+class.
18   - # b.wrapper :tag => "div", :class => "another" do |ba|
  18 + # b.wrapper tag: "div", class: "another" do |ba|
19 19 # ba.use :label
20 20 # ba.use :input
21 21 # end
22 22 #
23 23 # # Use a set of components by wrapping them in a tag+class.
24 24 # # This wrapper is identified by :label_input, which means it can
25   - # # be turned off on demand with `f.input :name, :label_input => false`
26   - # b.wrapper :label_input, :tag => "div", :class => "another" do |ba|
  25 + # # be turned off on demand with `f.input :name, label_input: false`
  26 + # b.wrapper :label_input, tag: "div", class: "another" do |ba|
27 27 # ba.use :label
28 28 # ba.use :input
29 29 # end
@@ -32,7 +32,7 @@ module Wrappers
32 32 # The builder also accepts default options at the root level. This is usually
33 33 # used if you want a component to be disabled by default:
34 34 #
35   - # config.wrappers :hint => false do |b|
  35 + # config.wrappers hint: false do |b|
36 36 # b.use :hint
37 37 # b.use :label_input
38 38 # end
126 test/action_view_extensions/builder_test.rb
@@ -58,21 +58,21 @@ def with_collection_check_boxes(object, attribute, collection, value_method, tex
58 58 end
59 59
60 60 test "collection radio accepts checked item" do
61   - with_collection_radio_buttons @user, :active, [[1, true], [0, false]], :last, :first, :checked => true
  61 + with_collection_radio_buttons @user, :active, [[1, true], [0, false]], :last, :first, checked: true
62 62
63 63 assert_select 'form input[type=radio][value=true][checked=checked]'
64 64 assert_no_select 'form input[type=radio][value=false][checked=checked]'
65 65 end
66 66
67 67 test "collection radio accepts checked item which has a value of false" do
68   - with_collection_radio_buttons @user, :active, [[1, true], [0, false]], :last, :first, :checked => false
  68 + with_collection_radio_buttons @user, :active, [[1, true], [0, false]], :last, :first, checked: false
69 69 assert_no_select 'form input[type=radio][value=true][checked=checked]'
70 70 assert_select 'form input[type=radio][value=false][checked=checked]'
71 71 end
72 72
73 73 test "collection radio accepts multiple disabled items" do
74 74 collection = [[1, true], [0, false], [2, 'other']]
75   - with_collection_radio_buttons @user, :active, collection, :last, :first, :disabled => [true, false]
  75 + with_collection_radio_buttons @user, :active, collection, :last, :first, disabled: [true, false]
76 76
77 77 assert_select 'form input[type=radio][value=true][disabled=disabled]'
78 78 assert_select 'form input[type=radio][value=false][disabled=disabled]'
@@ -81,7 +81,7 @@ def with_collection_check_boxes(object, attribute, collection, value_method, tex
81 81
82 82 test "collection radio accepts single disable item" do
83 83 collection = [[1, true], [0, false]]
84   - with_collection_radio_buttons @user, :active, collection, :last, :first, :disabled => true
  84 + with_collection_radio_buttons @user, :active, collection, :last, :first, disabled: true
85 85
86 86 assert_select 'form input[type=radio][value=true][disabled=disabled]'
87 87 assert_no_select 'form input[type=radio][value=false][disabled=disabled]'
@@ -89,50 +89,50 @@ def with_collection_check_boxes(object, attribute, collection, value_method, tex
89 89
90 90 test "collection radio accepts html options as input" do
91 91 collection = [[1, true], [0, false]]
92   - with_collection_radio_buttons @user, :active, collection, :last, :first, {}, :class => 'special-radio'
  92 + with_collection_radio_buttons @user, :active, collection, :last, :first, {}, class: 'special-radio'
93 93
94 94 assert_select 'form input[type=radio][value=true].special-radio#user_active_true'
95 95 assert_select 'form input[type=radio][value=false].special-radio#user_active_false'
96 96 end
97 97
98 98 test "collection radio wraps the collection in the given collection wrapper tag" do
99   - with_collection_radio_buttons @user, :active, [true, false], :to_s, :to_s, :collection_wrapper_tag => :ul
  99 + with_collection_radio_buttons @user, :active, [true, false], :to_s, :to_s, collection_wrapper_tag: :ul
100 100
101   - assert_select 'form ul input[type=radio]', :count => 2
  101 + assert_select 'form ul input[type=radio]', count: 2
102 102 end
103 103
104 104 test "collection radio does not render any wrapper tag by default" do
105 105 with_collection_radio_buttons @user, :active, [true, false], :to_s, :to_s
106 106
107   - assert_select 'form input[type=radio]', :count => 2
  107 + assert_select 'form input[type=radio]', count: 2
108 108 assert_no_select 'form ul'
109 109 end
110 110
111 111 test "collection radio does not wrap the collection when given falsy values" do
112   - with_collection_radio_buttons @user, :active, [true, false], :to_s, :to_s, :collection_wrapper_tag => false
  112 + with_collection_radio_buttons @user, :active, [true, false], :to_s, :to_s, collection_wrapper_tag: false
113 113
114   - assert_select 'form input[type=radio]', :count => 2
  114 + assert_select 'form input[type=radio]', count: 2
115 115 assert_no_select 'form ul'
116 116 end
117 117
118 118 test "collection radio uses the given class for collection wrapper tag" do
119 119 with_collection_radio_buttons @user, :active, [true, false], :to_s, :to_s,
120   - :collection_wrapper_tag => :ul, :collection_wrapper_class => "items-list"
  120 + collection_wrapper_tag: :ul, collection_wrapper_class: "items-list"
121 121
122   - assert_select 'form ul.items-list input[type=radio]', :count => 2
  122 + assert_select 'form ul.items-list input[type=radio]', count: 2
123 123 end
124 124
125 125 test "collection radio uses no class for collection wrapper tag when no wrapper tag is given" do
126 126 with_collection_radio_buttons @user, :active, [true, false], :to_s, :to_s,
127   - :collection_wrapper_class => "items-list"
  127 + collection_wrapper_class: "items-list"
128 128
129   - assert_select 'form input[type=radio]', :count => 2
  129 + assert_select 'form input[type=radio]', count: 2
130 130 assert_no_select 'form ul'
131 131 assert_no_select '.items-list'
132 132 end
133 133
134 134 test "collection radio uses no class for collection wrapper tag by default" do
135   - with_collection_radio_buttons @user, :active, [true, false], :to_s, :to_s, :collection_wrapper_tag => :ul
  135 + with_collection_radio_buttons @user, :active, [true, false], :to_s, :to_s, collection_wrapper_tag: :ul
136 136