<p dir="auto">This is preferable to using SQL statements.</p>
<p dir="auto">I double checked the output of the <code class="notranslate">.or()</code> formulation, and apart from extra table names and quoting, it's the same query.</p>
<pre class="notranslate"><code class="notranslate">> print Trace.visible.where("visibility IN ('public', 'identifiable') OR user_id = ?", u).to_sql
SELECT "gpx_files".* FROM "gpx_files" WHERE "gpx_files"."visible" = TRUE
AND (visibility IN ('public', 'identifiable') OR user_id = 1)=> nil
> print Trace.visible.where(:visibility => %w[public identifiable]).or(Trace.visible.where(:user => u)).to_sql
SELECT "gpx_files".* FROM "gpx_files" WHERE "gpx_files"."visible" = TRUE
AND ("gpx_files"."visibility" IN ('public', 'identifiable') OR "gpx_files"."user_id" = 1)=> nil
</code></pre>
<hr>
<h4>You can view, comment on, or merge this pull request online at:</h4>
<p> <a href='https://github.com/openstreetmap/openstreetmap-website/pull/4136'>https://github.com/openstreetmap/openstreetmap-website/pull/4136</a></p>
<h4>Commit Summary</h4>
<ul>
<li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/4136/commits/68fa607811e681535cc3db03d3a57a4654dd8292" class="commit-link">68fa607</a> Use hashes to define where..in sql queries</li>
</ul>
<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/openstreetmap/openstreetmap-website/pull/4136/files">2 files</a>)</p>
<ul>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/4136/files#diff-766c34fd6533171eaf54300c153f89d6002c35c02cfc9c5b219251f85180ad07">app/controllers/application_controller.rb</a>
(2)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/4136/files#diff-49ff8e13eb2bff9ffd834dad7421f568b40186cb58b28e7eac6b3e9168ec8759">app/models/trace.rb</a>
(2)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/4136.patch'>https://github.com/openstreetmap/openstreetmap-website/pull/4136.patch</a></li>
<li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/4136.diff'>https://github.com/openstreetmap/openstreetmap-website/pull/4136.diff</a></li>
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4136">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLLSGMKTIMTQLRWHXB3XTNZWDANCNFSM6AAAAAA3CQXTUI">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLJLCE2ZQR7OS7XBSELXTNZWDA5CNFSM6AAAAAA3CQXTUKWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHG2W7DM4.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/4136</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/4136",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/4136",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>