find function in rails code example
Example: self.find_by_id
def self.find_by_id(id)
sql = <<-SQL
SELECT * FROM dogs WHERE id = ?
SQL
DB[:conn].execute(sql, id).map(){|row|
self.new_from_db(row)
}.first
end
def self.find_by_id(id)
sql = <<-SQL
SELECT * FROM dogs WHERE id = ?
SQL
DB[:conn].execute(sql, id).map(){|row|
self.new_from_db(row)
}.first
end