2 回答

TA贡献1801条经验 获得超8个赞
Business.find_by_sql["SELECT d.name FROM businesses AS b
JOIN employees AS e ON (b.employee_id = e.id)
JOIN departments AS d ON (e.department_id = d.id)
WHERE d.code = ? AND b.out_date <= ? AND b.out_date > ?", department, upThe, downThe]

TA贡献1864条经验 获得超6个赞
{:Department => 'department',:UpThe=> 'upThe',:DownThe=> 'downThe'}
你怎么这样写。。
api
# You can use the same string replacement techniques as you can with ActiveRecord#find
Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date]
> [#<Post:0x36bff9c @attributes={"first_name"=>"The Cheap Man Buys Twice"}>, ...]
添加回答
举报