Rails 4.1 has enums available. I checked it out and it seemed to be working great in the rails console. When I try to persist data from a view to the database through my controller I get the following error
'Registration' is not a valid stream_type
Below is my class
class Stream < ActiveRecord::Base
enum stream_type: { sales: 1, registration: 2, student: 3 }
belongs_to :course_presentation
has_many :subscriptions
has_many :contacts, :through => :subscriptions
validates :course_presentation_id, :stream_type, presence: true
end
Below is the code i use to save
@stream = Stream.new(stream_params)
def stream_params
params.require(:stream).permit(:stream_type, :course_presentation_id, :is_active, :created_by_user_id, :updated_by_user_id)
end
below is the view code
<%= f.label :stream_type %><br>
<%= f.collection_select :stream_type, StreamType.order(:name), :name, :name, include_blank: "<-- select -->" %>
Any ideas? I just can't get it working