Created
July 7, 2013 17:43
-
-
Save mbhnyc/5944282 to your computer and use it in GitHub Desktop.
1 Way to store constants on the model and use in a view
This file contains 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
# In model: | |
STATUS_CHOICES = { | |
default: "Ask me", | |
single: "Single", | |
relationship: "Relationship", | |
married: "Married", | |
divorced: "Divorced", | |
complicated: "Takes some explaining", | |
open: "Open Relationship", | |
separated: "Separated" | |
} | |
# In edit view (simplified): | |
= simple_form_for resource, as: resource_name, url: registration_path(resource_name), html: {multipart: true, method: :put, class: 'inline' } do |f| | |
.inputs | |
= f.simple_fields_for :datingprofile do |dp| | |
= dp.input :relationship_status, required: true, label: "Status: ", collection: Datingprofile::STATUS_CHOICES.invert |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment