Module: ActiveRecord::FindByExtension

Included in:
Base
Defined in:
lib/vex/active_record/find_by_extension.rb

Instance Method Summary collapse

Instance Method Details

#find_all_by(args, opts = nil) ⇒ Object



2
3
4
5
6
# File 'lib/vex/active_record/find_by_extension.rb', line 2

def find_all_by(args, opts = nil)
  return find(:all, :conditions => args) if opts.nil?

  with_scope(:find => opts) do find_all_by(args) end
end

#find_by(args, opts = nil) ⇒ Object



8
9
10
11
12
# File 'lib/vex/active_record/find_by_extension.rb', line 8

def find_by(args, opts = nil)
  return find(:first, :conditions => args) if opts.nil?

  with_scope(:find => opts) do find_by(args) end
end

#find_by!(args, opts = nil) ⇒ Object



14
15
16
17
# File 'lib/vex/active_record/find_by_extension.rb', line 14

def find_by!(args, opts = nil)
  find_by(args, opts) || 
    raise(ActiveRecord::RecordNotFound, "Couldn't find #{self} with #{args.inspect}")
end