Documentation says Ohm lists are treated just like a Ruby array, but I see the following issues:
MyModel.new
in rails console produces:
ArgumentError: wrong number of arguments (1 for 2)
That's on a line where I have list :foo
where foo should be an array of integers.
Then, to follow up, I wanted to create a unique index on attribute :bar
and I get the following when I comment out the list method and add unique:
NoMethodError: undefined method `unique' for MyModel:Class
Here's the class:
class MyModel < Ohm::Model
attribute :email
list :foo
unique :email
end
This entire thing breaks down unless I comment out both the list and unique directives.
Are you looking for assert_unique
?
class MyModel < Ohm::Model
attribute :email
index :email
def validate
assert_unique :email
end
end