subsql = s.where(s[:name].matches("%#{site}%")).project(s[:id])
Incident.where(i[:supportable_type].eq('Site').and(i[:supportable_id].in([subsql]))).to_sql
=> "SELECT \"tickets\".* FROM \"tickets\" WHERE (\"tickets\".\"type\" = 'Incident') AND (\"tickets\".\"supportable_type\" = 'Site' AND \"tickets\".\"supportable_id\" IN (SELECT id FROM \"sites\" WHERE (\"sites\".\"name\" ILIKE '%Site A%')))"
Tuesday, January 11, 2011
Rails arel/activerelation subquery gotcha
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2011
(29)
-
▼
January
(11)
- Show diff in git stash
- Hard refresh for browsers on Mac OSX
- Multiple domains with Nginx
- Sort lines in Vim
- Setup Google apps (gmail) for .SG domain registere...
- Difference between includes and joins in rails
- Rails arel/activerelation subquery gotcha
- Overide default scope in Rails
- Setting up node.js and npm on Mac OSX
- URL for Google's OpenID
- Cucumber: Running a single feature / scenario
-
▼
January
(11)
No comments:
Post a Comment