Skip to content

Instantly share code, notes, and snippets.

@johnnaegle
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnnaegle/baf9132c6f7f510bd2b3 to your computer and use it in GitHub Desktop.
Save johnnaegle/baf9132c6f7f510bd2b3 to your computer and use it in GitHub Desktop.
rails enums
class Issue < ActiveRecord::Base
enum :status => {:open => 1, :closed => 2, :reopened => 3, :inprogress => 4}
end
= form_for @issue do |form|
- options = Issue.statuses.map { |k,v| [k.to_s.titleize, k]}
= form.select :status, options_for_select(options, @issue.status), {:include_blank => true}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment