Skip to content

Instantly share code, notes, and snippets.

@jacobsimeon
Last active December 21, 2015 21:59
Show Gist options
  • Save jacobsimeon/6372234 to your computer and use it in GitHub Desktop.
Save jacobsimeon/6372234 to your computer and use it in GitHub Desktop.
<%= simple_form_for(@case) %>
...
<!-- in your fields for one of the spouses -->
<%= f.input :title, collection: User.title_options %>
...
<% end %>
class User
# create a constant which is only defined one time
TITLE_OPTIONS = ["Mr.", "Mrs.", "Ms."]
# to avoid having to adapt to changes in the
# way we retrieve the list of options,
# create a method on the User class itself which returns the constant
# (this is different from an instance method)
def self.title_options
TITLE_OPTIONS
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment