Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   ActiveRecord acting weird (http://www.velocityreviews.com/forums/t827938-activerecord-acting-weird.html)

mark 01-20-2006 07:29 PM

ActiveRecord acting weird
 
I got this out of a book so I'm pretty sure it should work:

class Folder < ActiveRecord::Base
def validate
if self.find_by_name(name)
errors.add("folder by that name exists")
end
end
end

but when I validate:

<%
f = Folder.find_by_name("New Folder")
%>

<%= f.valid? %>

I get this:
undefined method `find_by_name' for #<Folder:0x40a125f4>

Any ideas?
Thanks



All times are GMT. The time now is 12:39 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.