select

select(object, method, choices = nil, options = {}, html_options = {}, &block) Instance Public methods Create a select tag and a series of contained option tags for the provided object and method. The option currently held by the object will be selected, provided that the object is available. There are two possible formats for the choices parameter, corresponding to other helpers' output: A flat collection (see options_for_select). A nested collection (see grouped_options_fo

options_from_collection_for_select

options_from_collection_for_select(collection, value_method, text_method, selected = nil) Instance Public methods Returns a string of option tags that have been compiled by iterating over the collection and assigning the result of a call to the value_method as the option value and the text_method as the option text. options_from_collection_for_select(@people, 'id', 'name') # => <option value="#{person.id}">#{person.name}</option> This is more often than not used ins

options_for_select

options_for_select(container, selected = nil) Instance Public methods Accepts a container (hash, array, enumerable, your type) and returns a string of option tags. Given a container where the elements respond to first and last (such as a two-element array), the âlastsâ serve as option values and the âfirstsâ as option text. Hashes are turned into this form automatically, so the keys become âfirstsâ and values become lasts. If selected is specified, the matching âlastâ or element wi

option_groups_from_collection_for_select

option_groups_from_collection_for_select(collection, group_method, group_label_method, option_key_method, option_value_method, selected_key = nil) Instance Public methods Returns a string of <option> tags, like options_from_collection_for_select, but groups them by <optgroup> tags based on the object relationships of the arguments. Parameters: collection - An array of objects representing the <optgroup> tags. group_method - The name of a method which, when call

grouped_options_for_select

grouped_options_for_select(grouped_options, selected_key = nil, options = {}) Instance Public methods Returns a string of <option> tags, like options_for_select, but wraps them with <optgroup> tags: grouped_options = [ ['North America', [['United States','US'],'Canada']], ['Europe', ['Denmark','Germany','France']] ] grouped_options_for_select(grouped_options) grouped_options = { 'North America' => [['United States','US'], 'Canada'], 'Europe' => ['Denm

grouped_collection_select

grouped_collection_select(object, method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {}) Instance Public methods Returns <select>, <optgroup> and <option> tags for the collection of existing return values of method for object's class. The value returned from calling method on the instance object will be selected. If calling method returns nil, no selection is made without including :prompt or

collection_select

collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {}) Instance Public methods Returns <select> and <option> tags for the collection of existing return values of method for object's class. The value returned from calling method on the instance object will be selected. If calling method returns nil, no selection is made without including :prompt or :include_blank in the options hash. The :value_method and :text_method pa

collection_radio_buttons

collection_radio_buttons(object, method, collection, value_method, text_method, options = {}, html_options = {}, &block) Instance Public methods Returns radio button tags for the collection of existing return values of method for object's class. The value returned from calling method on the instance object will be selected. If calling method returns nil, no selection is made. The :value_method and :text_method parameters are methods to be called on each member of collection. Th

collection_check_boxes

collection_check_boxes(object, method, collection, value_method, text_method, options = {}, html_options = {}, &block) Instance Public methods Returns check box tags for the collection of existing return values of method for object's class. The value returned from calling method on the instance object will be selected. If calling method returns nil, no selection is made. The :value_method and :text_method parameters are methods to be called on each member of collection. The ret

week_field

week_field(object_name, method, options = {}) Instance Public methods Returns a #text_field of type âweekâ. week_field("user", "born_on") # => <input id="user_born_on" name="user[born_on]" type="week" /> The default value is generated by trying to call strftime with â%Y-W%Wâ on the object's value, which makes it behave as expected for instances of DateTime and ActiveSupport::TimeWithZone. @user.born_on = Date.new(1984, 5, 12) week_field("user", "born_on") # => <inpu