I am working through Rails for Zombies, loving the helpful tutorial and interested in others by the way….
My issue is as follows.
The tutorial ask me to
“Do both uniqueness and presence validation on a Zombie’s name on a single line, using the new syntax”
I have tried the following in the console at RfZ;
class Zombie < ActiveRecord::Base
validates_uniqueness_of :name, validates_presence_of :name
end
// AND //
class Zombie < ActiveRecord::Base
validates Name :uniqueness, :presence => true
end
The tutorial is asking for the new Rails 3 syntax. I understand the new syntax allows for multiple validation arguments in one line. Very nice, but how would I do this? Thanks in advance everyone.
-Ryan
Your second attempt is closer, but not quite correct. Try this:
FYI, the older syntax would be :