Ruby on Rails / Примеры использования find_by_sql

find_by_sql(sql, binds = []) public
A simple SQL query spanning multiple tables
Post.find_by_sql "SELECT p.title, FROM posts p, comments c WHERE = c.post_id">> [#"Ruby Meetup", "first_name"=>"Quentin"}>, ...]
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]> [#"The Cheap Man Buys Twice"}>, ...]

No comments:

Post a Comment