Module: SelectOptions
- Defined in:
- lib/select_options/select_options.rb
Instance Method Summary collapse
-
#select_with_options(method, options = {}, html_options = {}) ⇒ Object
Create a select tag and a series of contained option tags for the provided object and method.
Instance Method Details
#select_with_options(method, options = {}, html_options = {}) ⇒ Object
Create a select tag and a series of contained option tags for the provided object and method. Helper would take options from model's constant and translations to them from translations file. For example with @user: class User < ActiveRecord::Base ROLES = %w(admin user) ... end
in the template: f.select_with_options :role is the same that: f.select :role, User::ROLES.map { |value| [translation_for_this_value, value] }
This helper takes parameters like a rails select.
16 17 18 19 |
# File 'lib/select_options/select_options.rb', line 16 def (method, = {}, = {}) const_name = .delete(:source) select(method, @object.(method, const_name), , ) end |