I am having trouble accessing an enum value from the view layer in Rails.
I have an ActiveRecord model named Rule which has an enum operation defined:
class Rule < ActiveRecord::Base
enum operation: [:says, :contains]
end
I have passed a rule to my view and I am trying to access the operation field. The object returns nil, despite having a value.
= rule.inspect #=> #<Rule id: 2, operation: 1>
= rule.operation #=> Nil
= rule.operation.class #=> NilClass
When I attempt to access the operations field from my console, it works just fine.
rule.inspect #=> #<Rule id: 2, operation: 1>
rule.operation #=> "contains"
I verified that operation is not a ruby/rails keyword. Is there some trick to getting enums to show up in the view layer?
Thanks in advance!