Making those fancy advanced methods

How do you write a method thats similar to find_by_username, I want to
write a method that works dynamically like that, but I have no idea
where to begin...

Do you declare the method differently? How do you access the part of the
method header you want, i.e. username?


Take a look at method_missing, and specifically how ActiveRecord::Base
implements it in the Rails codebase.

method_missing is the method called when a method :slight_smile:
For example:

def method_missing(meth)
  puts "Called #{meth}, which was missing..."
  raise NoMethodError

Playing with that in a class should get you started.