<?xml version="1.0" encoding="UTF-8"?>
<ticket>
  <assigned-user-id type="integer">22033</assigned-user-id>
  <attachments-count type="integer">0</attachments-count>
  <closed type="boolean">true</closed>
  <created-at type="datetime">2009-06-16T17:38:32-04:00</created-at>
  <creator-id type="integer">41518</creator-id>
  <milestone-due-on type="datetime" nil="true"></milestone-due-on>
  <milestone-id type="integer" nil="true"></milestone-id>
  <number type="integer">92</number>
  <permalink>conflict-with-a-scope-on-a-column-beginning-with-the-name-of-an-association</permalink>
  <priority type="integer">37045</priority>
  <project-id type="integer">16601</project-id>
  <raw-data type="binary" nil="true" encoding="base64"></raw-data>
  <state>resolved</state>
  <tag>2.0.0</tag>
  <title> Conflict with a scope on a column beginning with the name of an association  </title>
  <updated-at type="datetime">2009-07-14T03:22:05-04:00</updated-at>
  <user-id type="integer">1368</user-id>
  <user-name>Georg Ledermann</user-name>
  <creator-name>etaque (at gmail)</creator-name>
  <assigned-user-name>Ben Johnson</assigned-user-name>
  <url>http://binarylogic.lighthouseapp.com/projects/16601/tickets/92</url>
  <original-body>This is a duplicate of the ticket on github (maybe the wrong place to post tickeds ?) :
http://github.com/binarylogic/searchlogic/issues#issue/2

Giving those models :
User has_many :classifieds
Classified

User has the column &quot;classifieds_count&quot;.

The following search throws an error, because Searchlogic seems to ignore User.classifieds_count column and try to search on the associated Classified model :
User.classifieds_count_greater_than(5)

undefined method `count_greater_than' for #&lt;Class:0x3db9234&gt;

Thanks
Emilien</original-body>
  <latest-body>This is a duplicate of the ticket on github (maybe the wrong place to post tickeds ?) :
http://github.com/binarylogic/searchlogic/issues#issue/2

Giving those models :
User has_many :classifieds
Classified

User has the column &quot;classifieds_count&quot;.

The following search throws an error, because Searchlogic seems to ignore User.classifieds_count column and try to search on the associated Classified model :
User.classifieds_count_greater_than(5)

undefined method `count_greater_than' for #&lt;Class:0x3db9234&gt;

Thanks
Emilien</latest-body>
  <original-body-html>&lt;div&gt;&lt;p&gt;This is a duplicate of the ticket on github (maybe the wrong
place to post tickeds ?) : &lt;a href=&quot;http://github.com/binarylogic/searchlogic/issues#issue&quot;&gt;http://github.com/binarylogic/se...&lt;/a&gt;/2&lt;/p&gt;
&lt;p&gt;Giving those models : User has_many :classifieds Classified&lt;/p&gt;
&lt;p&gt;User has the column &quot;classifieds_count&quot;.&lt;/p&gt;
&lt;p&gt;The following search throws an error, because Searchlogic seems
to ignore User.classifieds_count column and try to search on the
associated Classified model :
User.classifieds_count_greater_than(5)&lt;/p&gt;
&lt;p&gt;undefined method &lt;code&gt;count_greater_than' for #&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Thanks Emilien&lt;/p&gt;&lt;/div&gt;</original-body-html>
  <versions type="array">
    <version type="Ticket::Version">
      <assigned-user-id type="integer">22033</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>This is a duplicate of the ticket on github (maybe the wrong place to post tickeds ?) :
http://github.com/binarylogic/searchlogic/issues#issue/2

Giving those models :
User has_many :classifieds
Classified

User has the column &quot;classifieds_count&quot;.

The following search throws an error, because Searchlogic seems to ignore User.classifieds_count column and try to search on the associated Classified model :
User.classifieds_count_greater_than(5)

undefined method `count_greater_than' for #&lt;Class:0x3db9234&gt;

Thanks
Emilien</body>
      <body-html>&lt;div&gt;&lt;p&gt;This is a duplicate of the ticket on github (maybe the wrong
place to post tickeds ?) :&lt;br&gt;
&lt;a href=
&quot;http://github.com/binarylogic/searchlogic/issues#issue/2&quot;&gt;http://github.com/binarylogic/searchlogic/issues#issue/2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Giving those models :&lt;br&gt;
User has_many :classifieds&lt;br&gt;
Classified&lt;/p&gt;
&lt;p&gt;User has the column &quot;classifieds_count&quot;.&lt;/p&gt;
&lt;p&gt;The following search throws an error, because Searchlogic seems
to ignore User.classifieds_count column and try to search on the
associated Classified model :&lt;br&gt;
User.classifieds_count_greater_than(5)&lt;/p&gt;
&lt;p&gt;undefined method &lt;code&gt;count_greater_than' for
#&amp;lt;Class:0x3db9234&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;br&gt;
Emilien&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-06-16T17:38:32-04:00</created-at>
      <creator-id type="integer">41518</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">92</number>
      <permalink>conflict-with-a-scope-on-a-column-beginning-with-the-name-of-an-association</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16601</project-id>
      <state>new</state>
      <tag>2.0.0</tag>
      <title> Conflict with a scope on a column beginning with the name of an association  </title>
      <updated-at type="datetime">2009-06-16T17:38:35-04:00</updated-at>
      <user-id type="integer">41518</user-id>
      <user-name>etaque (at gmail)</user-name>
      <creator-name>etaque (at gmail)</creator-name>
      <assigned-user-name>Ben Johnson</assigned-user-name>
      <url>http://binarylogic.lighthouseapp.com/projects/16601/tickets/92</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">22033</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Good find, for this I feel like &quot;xxx_count&quot; is obviously a standard, so making a exception for columns like that wouldn't be a huge deal. Also, my regex checks should check the column first anyways. I'll look into this though.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Good find, for this I feel like &quot;xxx_count&quot; is obviously a
standard, so making a exception for columns like that wouldn't be a
huge deal. Also, my regex checks should check the column first
anyways. I'll look into this though.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-06-20T04:58:51-04:00</created-at>
      <creator-id type="integer">41518</creator-id>
      <diffable-attributes type="yaml">--- 
:state: new
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">92</number>
      <permalink>conflict-with-a-scope-on-a-column-beginning-with-the-name-of-an-association</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16601</project-id>
      <state>open</state>
      <tag>2.0.0</tag>
      <title> Conflict with a scope on a column beginning with the name of an association  </title>
      <updated-at type="datetime">2009-06-20T04:58:52-04:00</updated-at>
      <user-id type="integer">22033</user-id>
      <user-name>Ben Johnson</user-name>
      <creator-name>etaque (at gmail)</creator-name>
      <assigned-user-name>Ben Johnson</assigned-user-name>
      <url>http://binarylogic.lighthouseapp.com/projects/16601/tickets/92</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">22033</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Simimilar problem here: 

@@@ ruby
class Debt &lt; ActiveRecord::Base
  belongs_to :creditor, :class_name =&gt; 'Contact', :foreign_key =&gt; 'creditor_contact_id'
  belongs_to :creditor_ledger, :class_name =&gt; 'Ledger', :foreign_key =&gt; 'creditor_ledger_id'
end

Debt.search(:creditor_ledger_id =&gt; 123)

# =&gt; NoMethodError: undefined method `ledger_id_equals' for #&lt;Class:0x268a720&gt;
@@@ ruby</body>
      <body-html>&lt;div&gt;&lt;p&gt;Simimilar problem here:&lt;/p&gt;
&lt;pre&gt;
&lt;code class=&quot;ruby&quot;&gt;class Debt &amp;lt; ActiveRecord::Base
  belongs_to :creditor, :class_name =&amp;gt; 'Contact', :foreign_key =&amp;gt; 'creditor_contact_id'
  belongs_to :creditor_ledger, :class_name =&amp;gt; 'Ledger', :foreign_key =&amp;gt; 'creditor_ledger_id'
end

Debt.search(:creditor_ledger_id =&amp;gt; 123)

# =&amp;gt; NoMethodError: undefined method `ledger_id_equals' for #&amp;lt;Class:0x268a720&amp;gt;&lt;/code&gt;
&lt;/pre&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-07-06T12:48:30-04:00</created-at>
      <creator-id type="integer">41518</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">92</number>
      <permalink>conflict-with-a-scope-on-a-column-beginning-with-the-name-of-an-association</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16601</project-id>
      <state>open</state>
      <tag>2.0.0</tag>
      <title> Conflict with a scope on a column beginning with the name of an association  </title>
      <updated-at type="datetime">2009-07-06T12:48:31-04:00</updated-at>
      <user-id type="integer">1368</user-id>
      <user-name>Georg Ledermann</user-name>
      <creator-name>etaque (at gmail)</creator-name>
      <assigned-user-name>Ben Johnson</assigned-user-name>
      <url>http://binarylogic.lighthouseapp.com/projects/16601/tickets/92</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">22033</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Did anyone come up with a quick fix for this bug? I would love to have it! Please let me know!</body>
      <body-html>&lt;div&gt;&lt;p&gt;Did anyone come up with a quick fix for this bug? I would love
to have it! Please let me know!&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-07-07T10:42:11-04:00</created-at>
      <creator-id type="integer">41518</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">92</number>
      <permalink>conflict-with-a-scope-on-a-column-beginning-with-the-name-of-an-association</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16601</project-id>
      <state>open</state>
      <tag>2.0.0</tag>
      <title> Conflict with a scope on a column beginning with the name of an association  </title>
      <updated-at type="datetime">2009-07-07T10:42:12-04:00</updated-at>
      <user-id type="integer">49070</user-id>
      <user-name>Joost</user-name>
      <creator-name>etaque (at gmail)</creator-name>
      <assigned-user-name>Ben Johnson</assigned-user-name>
      <url>http://binarylogic.lighthouseapp.com/projects/16601/tickets/92</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">22033</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>To fix this change line 83 of named_scopes/associatiions.rb to:

@@@ruby
  {:order_as =&gt; $1, :association =&gt; $2, :column =&gt; $3} unless column_names.include?(&quot;#{$2}_#{$3}&quot;)
@@@</body>
      <body-html>&lt;div&gt;&lt;p&gt;To fix this change line 83 of named_scopes/associatiions.rb
to:&lt;/p&gt;
&lt;p&gt;@@@ruby {:order_as =&amp;gt; $1, :association =&amp;gt; $2, :column
=&amp;gt; $3} unless column_names.include?(&quot;#{$2}_#{$3}&quot;)&lt;/p&gt;
&lt;pre&gt;

&lt;/pre&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-07-13T04:53:15-04:00</created-at>
      <creator-id type="integer">41518</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">92</number>
      <permalink>conflict-with-a-scope-on-a-column-beginning-with-the-name-of-an-association</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16601</project-id>
      <state>open</state>
      <tag>2.0.0</tag>
      <title> Conflict with a scope on a column beginning with the name of an association  </title>
      <updated-at type="datetime">2009-07-13T04:53:20-04:00</updated-at>
      <user-id type="integer">49070</user-id>
      <user-name>Joost</user-name>
      <creator-name>etaque (at gmail)</creator-name>
      <assigned-user-name>Ben Johnson</assigned-user-name>
      <url>http://binarylogic.lighthouseapp.com/projects/16601/tickets/92</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">22033</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>This has been fixed. Thanks!</body>
      <body-html>&lt;div&gt;&lt;p&gt;This has been fixed. Thanks!&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-07-13T16:54:10-04:00</created-at>
      <creator-id type="integer">41518</creator-id>
      <diffable-attributes type="yaml">--- 
:state: open
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">92</number>
      <permalink>conflict-with-a-scope-on-a-column-beginning-with-the-name-of-an-association</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16601</project-id>
      <state>resolved</state>
      <tag>2.0.0</tag>
      <title> Conflict with a scope on a column beginning with the name of an association  </title>
      <updated-at type="datetime">2009-07-13T16:54:11-04:00</updated-at>
      <user-id type="integer">22033</user-id>
      <user-name>Ben Johnson</user-name>
      <creator-name>etaque (at gmail)</creator-name>
      <assigned-user-name>Ben Johnson</assigned-user-name>
      <url>http://binarylogic.lighthouseapp.com/projects/16601/tickets/92</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">22033</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Works fine, thank you!</body>
      <body-html>&lt;div&gt;&lt;p&gt;Works fine, thank you!&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-07-14T03:22:04-04:00</created-at>
      <creator-id type="integer">41518</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">92</number>
      <permalink>conflict-with-a-scope-on-a-column-beginning-with-the-name-of-an-association</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">16601</project-id>
      <state>resolved</state>
      <tag>2.0.0</tag>
      <title> Conflict with a scope on a column beginning with the name of an association  </title>
      <updated-at type="datetime">2009-07-14T03:22:05-04:00</updated-at>
      <user-id type="integer">1368</user-id>
      <user-name>Georg Ledermann</user-name>
      <creator-name>etaque (at gmail)</creator-name>
      <assigned-user-name>Ben Johnson</assigned-user-name>
      <url>http://binarylogic.lighthouseapp.com/projects/16601/tickets/92</url>
    </version>
  </versions>
</ticket>
