Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Connor McCrone
452 Pointsgetting "undefined method 'validates'" error after validating format video.
Anyone know how I can fix this error?
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/dynamic_matchers.rb:55:in method_missing': undefined methodValidates' for #<Class:0x007fed56aa8f98> (NoMethodError)
My code all seems to be the same as in the video. I'm wondering if I'm getting the error because I don't have any created users on the site? Or maybe I'm missing a gem or something?
I checked stack overflow and all over google for an answer but can't seem to figure this out. Please help!
4 Answers
Jason Seifer
Treehouse Guest TeacherTry changing "validates" to "validate" in your code and let us know if you still have problems.
Connor McCrone
452 PointsThat did not work either. Here is my code so far...
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name, :profile_name
Validate :first_name, presence: true
Validate :last_name, presence: true
Validate :profile_name, presence: true, uniqueness: true, format: { with: /a-zA-Z0-9_-/, message: 'Must be formatted correctly.' }
has_many :statuses
def full_name
first_name + " " + last_name
end
end
Jason Seifer
Treehouse Guest TeacherTry chaning "Validate" to "validate" with the first letter lower cased and let us know how it works out.
Connor McCrone
452 PointsYes, that worked! Thank you for your help!