undefined method - what am I missing?

When I run this, I get a no method error: "undefined method `find_public'"

It doesn't work in the console either:>> Source.find_private

NoMethodError: undefined method `find_private' for #<Class:0x2f36a18> from

Well you've defined an instance method on SourcesController, but you're trying to call a class method on Source instead. Not sure how you were expecting that to work. public is a magic word in ruby but you might be able to get away with it here.

Fred

Well you've defined an instance method on SourcesController, but you're trying to call a class method on Source instead. Not sure how you were expecting that to work. public is a magic word in ruby but you might be able to get away with it here.

Yes, I'm new to all of this, and I knew I was doing it wrong... But can you help me figure out how to do it right?

Frederick Cheung wrote:

public is a magic word in ruby but you might be able to get away with it here.

Fred

Right, the boolean field is called "live", not "public".... sorry for that confusion....

Well if you want to be able to say Source.find_private then you need

class Source < ActiveRecord::Base   def self.find_private     ...   end end

or (equivalently)

class Source < ActiveRecord::Base   class << self     def find_private       ...     end   end end

There's a slightly magic incantation needed to make a class method, but if it's not obvious why defining find_private on SourcesController is completely nonsensical then I suggest you read up on you object oriented programming (something like the pickaxe will introduce you to that and ruby at the same time)

Fred