mongo => 2.0.4
rails => 3.2.2
ruby => 1.8.7
I’m following a tutorial (actually a combination of some tutorials), and I have a relatively simple model and I’m working on a CRUD. Everything I’ve read says to put this:
class Foo
include Mongoid::Document
field :foo
validates :foo, presence: true
end
Everything was working at first, but I added the validates line. I get this error:
syntax error, unexpected ':', expecting kEND
validates :task, presence: true
I have to assume this is due to some older version of ruby. I also tried this:
class Foo
include Mongoid::Document
field :foo
validates :foo, presence => true
end
…but then I get
Unknown validator: 'FooValidator'
in my browser, but simply Unknown validator: 'Validator' when running guard (using rspec). I’m not sure what the issue is, and Google has been no help. It seems that either of the two blocks that I have should work.
Change
...:foo, presenceto...:foo, :presence