I've got a problem with selecting enum value in form
here is a form
=form_for @ticket , remote: true do |f|
= f.label :name, class: 'label_hidden'
= f.text_field :name, placeholder:'Input your name', class:'form-control'
= f.label :email, class: 'label_hidden'
= f.email_field :email, placeholder:'Input your email', class:'form-control'
= f.label :department, class: 'label_hidden'
= f.select :department, Ticket.departments.keys , class:'form-control'
= f.submit 'Submit', class:'btn btn-default custom'
class Ticket < ActiveRecord::Base
enum department: [:issue, :qa, :promotion]
validates :name, :email, :subject, :body, :department, presence: true
I suppose that you receive enum as a String, so you should convert it with setter method:
def department=(val) self[:department] = val.to_sym end