ActiveRecord acting weird

Discussion in 'Ruby' started by mark, Jan 20, 2006.

  1. mark

    mark Guest

    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
     
    mark, Jan 20, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David
    Replies:
    5
    Views:
    398
    Juan T. Llibre
    Apr 21, 2005
  2. Jeff Epler
    Replies:
    0
    Views:
    527
    Jeff Epler
    Aug 20, 2004
  3. Jeff Epler
    Replies:
    0
    Views:
    474
    Jeff Epler
    Aug 23, 2004
  4. Gabriel B.

    scope acting weird

    Gabriel B., May 1, 2005, in forum: Python
    Replies:
    1
    Views:
    410
    Mike Meyer
    May 1, 2005
  5. Merrigan

    ftplib acting weird

    Merrigan, May 4, 2007, in forum: Python
    Replies:
    1
    Views:
    409
    Carlos Hanson
    May 7, 2007
Loading...

Share This Page