Last active
December 21, 2015 21:59
-
-
Save jacobsimeon/6372234 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= simple_form_for(@case) %> | |
... | |
<!-- in your fields for one of the spouses --> | |
<%= f.input :title, collection: User.title_options %> | |
... | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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