Reputation: 23
I searched the net and here but could not figure out why this error is coming:
NoMethodError (undefined method `status' for #<Class:0x007f89f3
I have an enum defined in model as under:
class BookEntryAssignment < ActiveRecord::Base
enum status: [:pending, :"in-progress", :completed, :approved]
after_initialize :set_default_status, :if => :new_record?
def set_default_status
self.status ||= :pending
end
end
I get the error when I try to create a select list:
f.select(:status, BookEntryAssignment.status.keys.map {|status| [status.titleize,status] if(!status.eql'approved')}, {:class => 'form-control'})
I dont know why this is happening. It might be a very silly mistake from me but can't figure it out.
Upvotes: 1
Views: 2048
Reputation: 1259
Try BookEntryAssignment.statuses
per the docs at http://edgeapi.rubyonrails.org/classes/ActiveRecord/Enum.html
Upvotes: 3