<?xml version="1.0" encoding="UTF-8"?>
<tickets type="array">
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2007-09-29T05:27:11+02:00</created-at>
    <creator-id type="integer">8322</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">120</number>
    <permalink>paginate-association-with-finder_sql-raises-typeerror</permalink>
    <priority type="integer">32</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>invalid</state>
    <tag>will_paginate</tag>
    <title>Association with finder_sql raises TypeError</title>
    <updated-at type="datetime">2010-01-13T17:26:49+01:00</updated-at>
    <user-id type="integer">8322</user-id>
    <user-name>wildchild</user-name>
    <creator-name>wildchild</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/120</url>
    <original-body>In case when finder_sql || counter_sql is used, attempt to paginate association raises TypeError: can't convert nil into Array

Attached failing test case.</original-body>
    <latest-body>In case when finder_sql || counter_sql is used, attempt to paginate association raises TypeError: can't convert nil into Array

Attached failing test case.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;
In case when finder_sql || counter_sql is used, attempt to paginate association raises TypeError: can't convert nil into Array
&lt;/p&gt;&lt;p&gt;
Attached failing test case.
&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2009-06-25T03:42:02+02:00</created-at>
    <creator-id type="integer">42446</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">272</number>
    <permalink>per_page-and-composite_primary_keys</permalink>
    <priority type="integer">124</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>invalid</state>
    <tag>page</tag>
    <title>per_page and composite_primary_keys</title>
    <updated-at type="datetime">2009-06-27T16:02:07+02:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>mephux</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/272</url>
    <original-body>It seems per_page breaks when using the composite_primary_keys plugin. Seems to put a limit for both ids and duplicating items.

vent Load (0.6ms)   SELECT * FROM `event` ORDER BY timestamp DESC LIMIT 50, 5</original-body>
    <latest-body>It seems per_page breaks when using the composite_primary_keys plugin. Seems to put a limit for both ids and duplicating items.

vent Load (0.6ms)   SELECT * FROM `event` ORDER BY timestamp DESC LIMIT 50, 5</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;It seems per_page breaks when using the composite_primary_keys
plugin. Seems to put a limit for both ids and duplicating
items.&lt;/p&gt;
&lt;p&gt;vent Load (0.6ms) SELECT * FROM &lt;code&gt;event&lt;/code&gt; ORDER BY
timestamp DESC LIMIT 50, 5&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-06-25T04:04:54+02:00</created-at>
    <creator-id type="integer">36253</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">273</number>
    <permalink>passing-nil-to-paginate_by_-fails</permalink>
    <priority type="integer">125</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>paginate_by will_paginate</tag>
    <title>Passing nil to paginate_by_* fails</title>
    <updated-at type="datetime">2009-06-25T04:04:57+02:00</updated-at>
    <user-id type="integer">36253</user-id>
    <user-name>Nick Hoffman</user-name>
    <creator-name>Nick Hoffman</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/273</url>
    <original-body>Hi guys. I'm using:
* will_paginate 2.3.8
* Rails 2.3.2
* Ruby 1.8.7

I noticed that searching for a nil value using #paginate_by_* fails with an error.

First, it works with an integer:
@@@
?&gt; Keyword.paginate_by_number_of_google_results 12_000, :page =&gt; 1
=&gt; [#&lt;Keyword id: 110472, keyword: &quot;foo bar&quot;, estimated_cpc: #&lt;BigDecimal:3a91138,'0.5342E2',8(8)&gt;, created_at: &quot;2009-06-25 01:30:11&quot;, updated_at: &quot;2009-06-25 01:33:54&quot;, keyword_list_id: 35, hot: nil, number_of_google_results: 12000&gt;]
@@@

However, it fails with nil:
@@@
Keyword.paginate_by_number_of_google_results nil, :page =&gt; 1
ActiveRecord::PreparedStatementInvalid: wrong number of bind variables (0 for 1) in: `keywords`.`number_of_google_results` is ?
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2399:in `raise_if_bind_arity_mismatch'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2351:in `replace_bind_variables'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2342:in `sanitize_sql_array'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2235:in `sanitize_sql_orig'
        from /Users/nick/src/adsense_keywords/vendor/gems/ar-extensions-0.9.1/lib/ar-extensions/finders.rb:35:in `sanitize_sql'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1499:in `merge_conditions'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1497:in `each'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1497:in `merge_conditions'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2122:in `with_scope'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2116:in `each'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2116:in `with_scope'
        from (irb):119:in `inject'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2112:in `each'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2112:in `inject'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2112:in `with_scope'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `send'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `count'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:223:in `wp_count'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in `with_scope'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `send'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `with_scope'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:233:in `wp_count'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:85:in `paginate'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:87:in `create'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:76:in `paginate'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:184:in `method_missing'
        from (irb):119
@@@

The line above should be equivalent to this:
@@@
Keyword.paginate :conditions =&gt; {:number_of_google_results =&gt; nil}, :page =&gt; 1
@@@

Cheers,
Nick

---

Here's the output from running the will_paginate tests:
@@@
$ rake test
(in /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8)
/opt/local/bin/ruby -I&quot;/Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib&quot; -I&quot;/Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/test&quot; &quot;/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/rake_test_loader.rb&quot; &quot;test/collection_test.rb&quot; &quot;test/finder_test.rb&quot; &quot;test/view_test.rb&quot; 
using Rails gems
Loaded suite /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/rake_test_loader
Started
.......................................E......................................................
Finished in 0.897438 seconds.

  1) Error:
test_paginate_in_named_scope_on_hmt_association(FinderTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: near &quot;*&quot;: syntax error: SELECT count(&quot;replies&quot;.*) AS count_replies_all FROM &quot;replies&quot; INNER JOIN &quot;topics&quot; ON &quot;replies&quot;.topic_id = &quot;topics&quot;.id WHERE (((replies.created_at &gt; '2009-06-24 21:49:20') AND ((&quot;topics&quot;.project_id = 1))) AND ((&quot;topics&quot;.project_id = 1))) 
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:157:in `execute_without_counting'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:402:in `catch_schema_changes'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:157:in `execute_without_counting'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/test/lib/activerecord_test_connector.rb:69:in `execute'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:305:in `select'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:13:in `select_one'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:19:in `select_value'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:243:in `execute_simple_calculation'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:134:in `calculate'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:130:in `catch'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:130:in `calculate'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:48:in `count'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `count'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `count'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:223:in `wp_count'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:235:in `call'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:235:in `wp_count'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:85:in `paginate'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:87:in `create'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:76:in `paginate'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:145:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:145:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/named_scope.rb:183:in `method_missing'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `with_scope'
    (__DELEGATION__):2:in `__send__'
    (__DELEGATION__):2:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/named_scope.rb:182:in `method_missing'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `with_scope'
    (__DELEGATION__):2:in `__send__'
    (__DELEGATION__):2:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/named_scope.rb:179:in `method_missing'
    ./test/finder_test.rb:248:in `test_paginate_in_named_scope_on_hmt_association'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/test/lib/activerecord_test_case.rb:33:in `assert_queries'
    ./test/finder_test.rb:247:in `test_paginate_in_named_scope_on_hmt_association'
    /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/testing/setup_and_teardown.rb:62:in `__send__'
    /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/testing/setup_and_teardown.rb:62:in `run'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/test/lib/activerecord_test_case.rb:22:in `run'

94 tests, 349 assertions, 0 failures, 1 errors
rake aborted!
Command failed with status (1): [/opt/local/bin/ruby -I&quot;/Users/nick/src/ads...]

(See full trace by running task with --trace)
@@@</original-body>
    <latest-body>Hi guys. I'm using:
* will_paginate 2.3.8
* Rails 2.3.2
* Ruby 1.8.7

I noticed that searching for a nil value using #paginate_by_* fails with an error.

First, it works with an integer:
@@@
?&gt; Keyword.paginate_by_number_of_google_results 12_000, :page =&gt; 1
=&gt; [#&lt;Keyword id: 110472, keyword: &quot;foo bar&quot;, estimated_cpc: #&lt;BigDecimal:3a91138,'0.5342E2',8(8)&gt;, created_at: &quot;2009-06-25 01:30:11&quot;, updated_at: &quot;2009-06-25 01:33:54&quot;, keyword_list_id: 35, hot: nil, number_of_google_results: 12000&gt;]
@@@

However, it fails with nil:
@@@
Keyword.paginate_by_number_of_google_results nil, :page =&gt; 1
ActiveRecord::PreparedStatementInvalid: wrong number of bind variables (0 for 1) in: `keywords`.`number_of_google_results` is ?
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2399:in `raise_if_bind_arity_mismatch'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2351:in `replace_bind_variables'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2342:in `sanitize_sql_array'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2235:in `sanitize_sql_orig'
        from /Users/nick/src/adsense_keywords/vendor/gems/ar-extensions-0.9.1/lib/ar-extensions/finders.rb:35:in `sanitize_sql'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1499:in `merge_conditions'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1497:in `each'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1497:in `merge_conditions'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2122:in `with_scope'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2116:in `each'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2116:in `with_scope'
        from (irb):119:in `inject'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2112:in `each'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2112:in `inject'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2112:in `with_scope'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `send'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `count'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:223:in `wp_count'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in `with_scope'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `send'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `with_scope'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:233:in `wp_count'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:85:in `paginate'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:87:in `create'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:76:in `paginate'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:184:in `method_missing'
        from (irb):119
@@@

The line above should be equivalent to this:
@@@
Keyword.paginate :conditions =&gt; {:number_of_google_results =&gt; nil}, :page =&gt; 1
@@@

Cheers,
Nick

---

Here's the output from running the will_paginate tests:
@@@
$ rake test
(in /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8)
/opt/local/bin/ruby -I&quot;/Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib&quot; -I&quot;/Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/test&quot; &quot;/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/rake_test_loader.rb&quot; &quot;test/collection_test.rb&quot; &quot;test/finder_test.rb&quot; &quot;test/view_test.rb&quot; 
using Rails gems
Loaded suite /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/rake_test_loader
Started
.......................................E......................................................
Finished in 0.897438 seconds.

  1) Error:
test_paginate_in_named_scope_on_hmt_association(FinderTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: near &quot;*&quot;: syntax error: SELECT count(&quot;replies&quot;.*) AS count_replies_all FROM &quot;replies&quot; INNER JOIN &quot;topics&quot; ON &quot;replies&quot;.topic_id = &quot;topics&quot;.id WHERE (((replies.created_at &gt; '2009-06-24 21:49:20') AND ((&quot;topics&quot;.project_id = 1))) AND ((&quot;topics&quot;.project_id = 1))) 
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:157:in `execute_without_counting'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:402:in `catch_schema_changes'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:157:in `execute_without_counting'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/test/lib/activerecord_test_connector.rb:69:in `execute'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:305:in `select'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:13:in `select_one'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:19:in `select_value'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:243:in `execute_simple_calculation'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:134:in `calculate'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:130:in `catch'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:130:in `calculate'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:48:in `count'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `count'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `count'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:223:in `wp_count'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:235:in `call'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:235:in `wp_count'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:85:in `paginate'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:87:in `create'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:76:in `paginate'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:145:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:145:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/named_scope.rb:183:in `method_missing'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `with_scope'
    (__DELEGATION__):2:in `__send__'
    (__DELEGATION__):2:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/named_scope.rb:182:in `method_missing'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `with_scope'
    (__DELEGATION__):2:in `__send__'
    (__DELEGATION__):2:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/named_scope.rb:179:in `method_missing'
    ./test/finder_test.rb:248:in `test_paginate_in_named_scope_on_hmt_association'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/test/lib/activerecord_test_case.rb:33:in `assert_queries'
    ./test/finder_test.rb:247:in `test_paginate_in_named_scope_on_hmt_association'
    /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/testing/setup_and_teardown.rb:62:in `__send__'
    /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/testing/setup_and_teardown.rb:62:in `run'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/test/lib/activerecord_test_case.rb:22:in `run'

94 tests, 349 assertions, 0 failures, 1 errors
rake aborted!
Command failed with status (1): [/opt/local/bin/ruby -I&quot;/Users/nick/src/ads...]

(See full trace by running task with --trace)
@@@</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Hi guys. I'm using: * will_paginate 2.3.8 * Rails 2.3.2 * Ruby
1.8.7&lt;/p&gt;
&lt;p&gt;I noticed that searching for a nil value using #paginate_by_*
fails with an error.&lt;/p&gt;
&lt;p&gt;First, it works with an integer:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
?&amp;gt; Keyword.paginate_by_number_of_google_results 12_000, :page =&amp;gt; 1
=&amp;gt; [#&amp;lt;Keyword id: 110472, keyword: &amp;quot;foo bar&amp;quot;, estimated_cpc: #&amp;lt;BigDecimal:3a91138,'0.5342E2',8(8)&amp;gt;, created_at: &amp;quot;2009-06-25 01:30:11&amp;quot;, updated_at: &amp;quot;2009-06-25 01:33:54&amp;quot;, keyword_list_id: 35, hot: nil, number_of_google_results: 12000&amp;gt;]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, it fails with nil:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
Keyword.paginate_by_number_of_google_results nil, :page =&amp;gt; 1
ActiveRecord::PreparedStatementInvalid: wrong number of bind variables (0 for 1) in: `keywords`.`number_of_google_results` is ?
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2399:in `raise_if_bind_arity_mismatch'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2351:in `replace_bind_variables'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2342:in `sanitize_sql_array'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2235:in `sanitize_sql_orig'
        from /Users/nick/src/adsense_keywords/vendor/gems/ar-extensions-0.9.1/lib/ar-extensions/finders.rb:35:in `sanitize_sql'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1499:in `merge_conditions'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1497:in `each'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1497:in `merge_conditions'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2122:in `with_scope'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2116:in `each'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2116:in `with_scope'
        from (irb):119:in `inject'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2112:in `each'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2112:in `inject'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2112:in `with_scope'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `send'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `count'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:223:in `wp_count'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in `with_scope'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `send'
        from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `with_scope'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:233:in `wp_count'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:85:in `paginate'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:87:in `create'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:76:in `paginate'
        from /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:184:in `method_missing'
        from (irb):119
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The line above should be equivalent to this:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
Keyword.paginate :conditions =&amp;gt; {:number_of_google_results =&amp;gt; nil}, :page =&amp;gt; 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cheers, Nick&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Here's the output from running the will_paginate tests:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
$ rake test
(in /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8)
/opt/local/bin/ruby -I&amp;quot;/Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib&amp;quot; -I&amp;quot;/Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/test&amp;quot; &amp;quot;/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/rake_test_loader.rb&amp;quot; &amp;quot;test/collection_test.rb&amp;quot; &amp;quot;test/finder_test.rb&amp;quot; &amp;quot;test/view_test.rb&amp;quot; 
using Rails gems
Loaded suite /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/rake_test_loader
Started
.......................................E......................................................
Finished in 0.897438 seconds.

  1) Error:
test_paginate_in_named_scope_on_hmt_association(FinderTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: near &amp;quot;*&amp;quot;: syntax error: SELECT count(&amp;quot;replies&amp;quot;.*) AS count_replies_all FROM &amp;quot;replies&amp;quot; INNER JOIN &amp;quot;topics&amp;quot; ON &amp;quot;replies&amp;quot;.topic_id = &amp;quot;topics&amp;quot;.id WHERE (((replies.created_at &amp;gt; '2009-06-24 21:49:20') AND ((&amp;quot;topics&amp;quot;.project_id = 1))) AND ((&amp;quot;topics&amp;quot;.project_id = 1))) 
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:157:in `execute_without_counting'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:402:in `catch_schema_changes'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:157:in `execute_without_counting'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/test/lib/activerecord_test_connector.rb:69:in `execute'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:305:in `select'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:13:in `select_one'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:19:in `select_value'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:243:in `execute_simple_calculation'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:134:in `calculate'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:130:in `catch'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:130:in `calculate'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/calculations.rb:48:in `count'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `count'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:176:in `count'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:223:in `wp_count'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:235:in `call'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:235:in `wp_count'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:85:in `paginate'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:87:in `create'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:76:in `paginate'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:145:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:145:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/named_scope.rb:183:in `method_missing'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `with_scope'
    (__DELEGATION__):2:in `__send__'
    (__DELEGATION__):2:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/named_scope.rb:182:in `method_missing'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `send'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_proxy.rb:206:in `with_scope'
    (__DELEGATION__):2:in `__send__'
    (__DELEGATION__):2:in `with_scope'
    /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/named_scope.rb:179:in `method_missing'
    ./test/finder_test.rb:248:in `test_paginate_in_named_scope_on_hmt_association'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/test/lib/activerecord_test_case.rb:33:in `assert_queries'
    ./test/finder_test.rb:247:in `test_paginate_in_named_scope_on_hmt_association'
    /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/testing/setup_and_teardown.rb:62:in `__send__'
    /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/testing/setup_and_teardown.rb:62:in `run'
    /Users/nick/src/adsense_keywords/vendor/gems/mislav-will_paginate-2.3.8/test/lib/activerecord_test_case.rb:22:in `run'

94 tests, 349 assertions, 0 failures, 1 errors
rake aborted!
Command failed with status (1): [/opt/local/bin/ruby -I&amp;quot;/Users/nick/src/ads...]

(See full trace by running task with --trace)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2008-06-18T22:27:51+02:00</created-at>
    <creator-id type="integer">20082</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">231</number>
    <permalink>option-to-omit-page-1-parameter-on-page-one</permalink>
    <priority type="integer">94</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>open</state>
    <tag>patch view will_paginate</tag>
    <title>Option to omit page=1 parameter on page one</title>
    <updated-at type="datetime">2009-06-10T20:05:37+02:00</updated-at>
    <user-id type="integer">52130</user-id>
    <user-name>ippa</user-name>
    <creator-name>Brad Folkens</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/231</url>
    <original-body>View helper should allow the omission of the page=1 URL parameter with the :omit_page_one option.</original-body>
    <latest-body>View helper should allow the omission of the page=1 URL parameter with the :omit_page_one option.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;
View helper should allow the omission of the page=1 URL parameter with the :omit_page_one option.
&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-05-29T12:26:27+02:00</created-at>
    <creator-id type="integer">35069</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">271</number>
    <permalink>add-support-for-i18n</permalink>
    <priority type="integer">123</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>helpers i18n localize view</tag>
    <title>Add support for i18n</title>
    <updated-at type="datetime">2009-05-29T12:26:28+02:00</updated-at>
    <user-id type="integer">35069</user-id>
    <user-name>Paul Springett</user-name>
    <creator-name>Paul Springett</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/271</url>
    <original-body>The ability to localize the view helpers without having to overwrite the helper methods (such as page_entries_info) would be awesome</original-body>
    <latest-body>The ability to localize the view helpers without having to overwrite the helper methods (such as page_entries_info) would be awesome</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;The ability to localize the view helpers without having to
overwrite the helper methods (such as page_entries_info) would be
awesome&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2009-05-27T22:35:27+02:00</created-at>
    <creator-id type="integer">58111</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">270</number>
    <permalink>include-brings-back-more-records-then-i-specify-per-page</permalink>
    <priority type="integer">122</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>invalid</state>
    <tag>include</tag>
    <title>:include brings back more records then I specify per page</title>
    <updated-at type="datetime">2009-05-27T23:13:48+02:00</updated-at>
    <user-id type="integer">58111</user-id>
    <user-name>Brian</user-name>
    <creator-name>Brian</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/270</url>
    <original-body>If I call paginate on a Model.all with an :include specified, the query that brings back the included records is pulling back all the records instead of only the included records for the current page.  Below is an example:

MspLocation.all(:include =&gt; [{:msp_profile =&gt; [:msp_services]}], :joins =&gt; [:msp_profile], :conditions =&gt; [&quot;country = ?&quot;, country], :order =&gt; &quot;company_name&quot;).paginate(:page =&gt; 1)
** I have the page size set to 30

the previous command generates the following log output

MspLocation Load (3.2ms)  SELECT &quot;msp_locations&quot;.* FROM &quot;msp_locations&quot; INNER JOIN &quot;msp_profiles&quot; ON &quot;msp_profiles&quot;.id = &quot;msp_locations&quot;.msp_profile_id WHERE (country = E'United States') ORDER BY company_name

MspProfile Load (1.2ms)  SELECT * FROM &quot;msp_profiles&quot; WHERE (&quot;msp_profiles&quot;.&quot;id&quot; IN (22,66,55,44,33,11,23,56,45,34,7,67,24,57,46,35,8,68,25,58,47,36,70,69,60,59,48,37,26,71,61,50,49,38,16,27,62,51,40,39,28,17,63,52,41,18,30,29,64,20,53,19,42,31,21,65,54,43,32,5))

As you can see, the second query is bringing back more then 30 records.  I would expect it to only bring back the records the view needs to display for the current page.</original-body>
    <latest-body>If I call paginate on a Model.all with an :include specified, the query that brings back the included records is pulling back all the records instead of only the included records for the current page.  Below is an example:

MspLocation.all(:include =&gt; [{:msp_profile =&gt; [:msp_services]}], :joins =&gt; [:msp_profile], :conditions =&gt; [&quot;country = ?&quot;, country], :order =&gt; &quot;company_name&quot;).paginate(:page =&gt; 1)
** I have the page size set to 30

the previous command generates the following log output

MspLocation Load (3.2ms)  SELECT &quot;msp_locations&quot;.* FROM &quot;msp_locations&quot; INNER JOIN &quot;msp_profiles&quot; ON &quot;msp_profiles&quot;.id = &quot;msp_locations&quot;.msp_profile_id WHERE (country = E'United States') ORDER BY company_name

MspProfile Load (1.2ms)  SELECT * FROM &quot;msp_profiles&quot; WHERE (&quot;msp_profiles&quot;.&quot;id&quot; IN (22,66,55,44,33,11,23,56,45,34,7,67,24,57,46,35,8,68,25,58,47,36,70,69,60,59,48,37,26,71,61,50,49,38,16,27,62,51,40,39,28,17,63,52,41,18,30,29,64,20,53,19,42,31,21,65,54,43,32,5))

As you can see, the second query is bringing back more then 30 records.  I would expect it to only bring back the records the view needs to display for the current page.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;If I call paginate on a Model.all with an :include specified,
the query that brings back the included records is pulling back all
the records instead of only the included records for the current
page. Below is an example:&lt;/p&gt;
&lt;p&gt;MspLocation.all(:include =&amp;gt; [{:msp_profile =&amp;gt;
[:msp_services]}], :joins =&amp;gt; [:msp_profile], :conditions =&amp;gt;
[&quot;country = ?&quot;, country], :order =&amp;gt;
&quot;company_name&quot;).paginate(:page =&amp;gt; 1) ** I have the page size set
to 30&lt;/p&gt;
&lt;p&gt;the previous command generates the following log output&lt;/p&gt;
&lt;p&gt;MspLocation Load (3.2ms) SELECT &quot;msp_locations&quot;.* FROM
&quot;msp_locations&quot; INNER JOIN &quot;msp_profiles&quot; ON &quot;msp_profiles&quot;.id =
&quot;msp_locations&quot;.msp_profile_id WHERE (country = E'United States')
ORDER BY company_name&lt;/p&gt;
&lt;p&gt;MspProfile Load (1.2ms) SELECT * FROM &quot;msp_profiles&quot; WHERE
(&quot;msp_profiles&quot;.&quot;id&quot; IN
(22,66,55,44,33,11,23,56,45,34,7,67,24,57,46,35,8,68,25,58,47,36,70,69,60,59,48,37,26,71,61,50,49,38,16,27,62,51,40,39,28,17,63,52,41,18,30,29,64,20,53,19,42,31,21,65,54,43,32,5))&lt;/p&gt;
&lt;p&gt;As you can see, the second query is bringing back more then 30
records. I would expect it to only bring back the records the view
needs to display for the current page.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2008-07-08T21:05:05+02:00</created-at>
    <creator-id type="integer">25668</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">237</number>
    <permalink>paginate_by_sql-fails-when-using-oracle-and-the-jdbc-driver</permalink>
    <priority type="integer">98</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>open</state>
    <tag>jdbc oracle will_paginate</tag>
    <title>paginate_by_sql fails when using Oracle and the jdbc driver.</title>
    <updated-at type="datetime">2009-05-21T23:36:17+02:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>squirrelbone</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/237</url>
    <original-body>Why not remove the following block of code altogether? 
@@@ ruby
unless ['oracle', 'oci'].include?(self.connection.adapter_name.downcase)
  count_query &lt;&lt; ' AS count_table'
end
@@@

When using JDBC connection.adapter_name shows up as jdbc regardless of the database. So this will fail for Oracle when using JDBC and when the inner select statement returns no rows.
@@@ ruby
count_query = &quot;SELECT COUNT(*) FROM (#{count_query})&quot;
@@@</original-body>
    <latest-body>Why not remove the following block of code altogether? 
@@@ ruby
unless ['oracle', 'oci'].include?(self.connection.adapter_name.downcase)
  count_query &lt;&lt; ' AS count_table'
end
@@@

When using JDBC connection.adapter_name shows up as jdbc regardless of the database. So this will fail for Oracle when using JDBC and when the inner select statement returns no rows.
@@@ ruby
count_query = &quot;SELECT COUNT(*) FROM (#{count_query})&quot;
@@@</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;
Why not remove the following block of code altogether?
&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;unless ['oracle', 'oci'].include?(self.connection.adapter_name.downcase)
  count_query &amp;lt;&amp;lt; ' AS count_table'
end&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
When using JDBC connection.adapter_name shows up as jdbc regardless of the database. So this will fail for Oracle when using JDBC and when the inner select statement returns no rows.
&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;count_query = &amp;quot;SELECT COUNT(*) FROM (#{count_query})&amp;quot;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2009-04-02T09:03:08+02:00</created-at>
    <creator-id type="integer">52778</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">267</number>
    <permalink>install-will_paginate-plug-in</permalink>
    <priority type="integer">119</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>invalid</state>
    <tag nil="true"></tag>
    <title>install will_paginate plug in</title>
    <updated-at type="datetime">2009-05-20T11:44:09+02:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>thiti</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/267</url>
    <original-body>Hello ,
i stall will_paginate plug in by using
&gt;&gt;mkdir vendor/plugins/will_paginate
&gt;&gt; wget -nv http://github.com/mislav/will_paginate/tarball/master -O- | \tar xzv -C vendor/plugins/will_paginate --strip 1
i get this
&gt;&gt;mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/.gitignore
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/.manifest
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/CHANGELOG.rdoc
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/LICENSE
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/README.rdoc
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/Rakefile
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/apple-circle.gif
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/index.haml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/index.html
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/pagination.css
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/pagination.sass
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/init.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/array.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/collection.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/core_ext.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/finder.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/named_scope.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/named_scope_patch.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/version.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/view_helpers.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/boot.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/collection_test.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/console
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/database.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/finder_test.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/admin.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/developer.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/developers_projects.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/project.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/projects.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/replies.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/reply.rb
2009-04-02 13:11:00 URL:http://download.github.com/mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556.tar.gz [36217/36217] -&gt; &quot;-&quot; [1]
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/schema.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/topic.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/topics.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/user.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/users.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/helper.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/activerecord_test_case.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/activerecord_test_connector.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/load_fixtures.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/view_test_process.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/tasks.rake
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/view_test.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/will_paginate.gemspec
 &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
after that i go to config/environments.rb
add the require &quot;will_paginate&quot; at the bottom
&gt;&gt;&gt;and try the script
&gt;&gt;s = Seq.paginate(:page =&gt; 1, :per_page =&gt; 5)
NameError: uninitialized constant Seq::Post
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:105:in `const_missing'
	from /home/apple/www/rcc_eri/app/models/seq.rb:7
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:380:in `load_without_new_constant_marking'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:380:in `load_file'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:379:in `load_file'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:259:in `require_or_load'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:425:in `load_missing_constant'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:92:in `const_missing'
	from (irb):2
&gt;&gt;&gt;pls ,tell me what i missing?
thank you</original-body>
    <latest-body>Hello ,
i stall will_paginate plug in by using
&gt;&gt;mkdir vendor/plugins/will_paginate
&gt;&gt; wget -nv http://github.com/mislav/will_paginate/tarball/master -O- | \tar xzv -C vendor/plugins/will_paginate --strip 1
i get this
&gt;&gt;mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/.gitignore
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/.manifest
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/CHANGELOG.rdoc
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/LICENSE
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/README.rdoc
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/Rakefile
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/apple-circle.gif
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/index.haml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/index.html
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/pagination.css
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/pagination.sass
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/init.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/array.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/collection.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/core_ext.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/finder.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/named_scope.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/named_scope_patch.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/version.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/view_helpers.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/boot.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/collection_test.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/console
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/database.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/finder_test.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/admin.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/developer.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/developers_projects.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/project.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/projects.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/replies.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/reply.rb
2009-04-02 13:11:00 URL:http://download.github.com/mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556.tar.gz [36217/36217] -&gt; &quot;-&quot; [1]
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/schema.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/topic.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/topics.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/user.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/users.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/helper.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/activerecord_test_case.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/activerecord_test_connector.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/load_fixtures.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/view_test_process.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/tasks.rake
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/view_test.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/will_paginate.gemspec
 &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
after that i go to config/environments.rb
add the require &quot;will_paginate&quot; at the bottom
&gt;&gt;&gt;and try the script
&gt;&gt;s = Seq.paginate(:page =&gt; 1, :per_page =&gt; 5)
NameError: uninitialized constant Seq::Post
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:105:in `const_missing'
	from /home/apple/www/rcc_eri/app/models/seq.rb:7
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:380:in `load_without_new_constant_marking'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:380:in `load_file'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:379:in `load_file'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:259:in `require_or_load'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:425:in `load_missing_constant'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:92:in `const_missing'
	from (irb):2
&gt;&gt;&gt;pls ,tell me what i missing?
thank you</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Hello , i stall will_paginate plug in by using&lt;/p&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;mkdir vendor/plugins/will_paginate wget -nv &lt;a href=&quot;http://github.com/mislav/will_paginate/tarball/master&quot;&gt;http://github.com/mislav/will_pa...&lt;/a&gt;
-O- | \tar xzv -C vendor/plugins/will_paginate --strip 1 i get this
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/.gitignore
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/.manifest
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/CHANGELOG.rdoc
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/LICENSE
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/README.rdoc
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/Rakefile
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/apple-circle.gif
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/index.haml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/index.html
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/pagination.css
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/examples/pagination.sass
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/init.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/array.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/collection.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/core_ext.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/finder.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/named_scope.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/named_scope_patch.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/version.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/view_helpers.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/boot.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/collection_test.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/console
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/database.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/finder_test.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/admin.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/developer.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/developers_projects.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/project.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/projects.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/replies.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/reply.rb
2009-04-02 13:11:00
URL:http://download.github.com/mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556.tar.gz
[36217/36217] -&amp;gt; &quot;-&quot; &lt;a href=&quot;/projects/17958/changesets/1&quot; title=&quot;Changeset #1&quot;&gt;[1]&lt;/a&gt;
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/schema.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/topic.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/topics.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/user.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/fixtures/users.yml
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/helper.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/activerecord_test_case.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/activerecord_test_connector.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/load_fixtures.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/lib/view_test_process.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/tasks.rake
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/test/view_test.rb
mislav-will_paginate-8888651be8d6656bdf2378731d91a8badbaa2556/will_paginate.gemspec
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
after that i go to config/environments.rb add the require
&quot;will_paginate&quot; at the bottom&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;and try the script s = Seq.paginate(:page =&amp;gt; 1, :per_page
=&amp;gt; 5) NameError: uninitialized constant Seq::Post&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:105:in `const_missing'
from /home/apple/www/rcc_eri/app/models/seq.rb:7
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:380:in `load_without_new_constant_marking'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:380:in `load_file'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:379:in `load_file'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:259:in `require_or_load'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:425:in `load_missing_constant'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:92:in `const_missing'
from (irb):2
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;pls ,tell me what i missing? thank you&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2009-05-06T17:26:39+02:00</created-at>
    <creator-id type="integer">15518</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">269</number>
    <permalink>problem-with-ruby-19x</permalink>
    <priority type="integer">121</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>resolved</state>
    <tag>associations bug count options patch ruby1.9</tag>
    <title>Problem with Ruby 1.9.x</title>
    <updated-at type="datetime">2009-05-20T11:42:41+02:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>Anton Ageev</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/269</url>
    <original-body>In Ruby 1.9.x `WillPaginate::Finder::ClassMethods#wp_count` doesn't remove `:include` options in following code:

    # forget about includes if they are irrelevant (Rails 2.1)
    if count_options[:include] and
        klass.private_methods.include?('references_eager_loaded_tables?') and
        !klass.send(:references_eager_loaded_tables?, count_options)
      count_options.delete :include
    end

`klass.private_methods` in ruby 1.8.x returns strings, in ruby 1.9.x returns symbols.

Oneline patch:

    - klass.private_methods.include?('references_eager_loaded_tables?')
    + klass.private_methods.map { |n| n.to_sym }.include?(:references_eager_loaded_tables?)</original-body>
    <latest-body>In Ruby 1.9.x `WillPaginate::Finder::ClassMethods#wp_count` doesn't remove `:include` options in following code:

    # forget about includes if they are irrelevant (Rails 2.1)
    if count_options[:include] and
        klass.private_methods.include?('references_eager_loaded_tables?') and
        !klass.send(:references_eager_loaded_tables?, count_options)
      count_options.delete :include
    end

`klass.private_methods` in ruby 1.8.x returns strings, in ruby 1.9.x returns symbols.

Oneline patch:

    - klass.private_methods.include?('references_eager_loaded_tables?')
    + klass.private_methods.map { |n| n.to_sym }.include?(:references_eager_loaded_tables?)</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;In Ruby 1.9.x
&lt;code&gt;WillPaginate::Finder::ClassMethods#wp_count&lt;/code&gt; doesn't
remove &lt;code&gt;:include&lt;/code&gt; options in following code:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;# forget about includes if they are irrelevant (Rails 2.1)
if count_options[:include] and
    klass.private_methods.include?('references_eager_loaded_tables?') and
    !klass.send(:references_eager_loaded_tables?, count_options)
  count_options.delete :include
end
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;klass.private_methods&lt;/code&gt; in ruby 1.8.x returns
strings, in ruby 1.9.x returns symbols.&lt;/p&gt;
&lt;p&gt;Oneline patch:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;- klass.private_methods.include?('references_eager_loaded_tables?')
+ klass.private_methods.map { |n| n.to_sym }.include?(:references_eager_loaded_tables?)
&lt;/code&gt;
&lt;/pre&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-04-17T12:58:46+02:00</created-at>
    <creator-id type="integer">34931</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">268</number>
    <permalink>exception-in-rails-232-when-using-group</permalink>
    <priority type="integer">120</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>open</state>
    <tag>group orderedhash rails-2.3.2</tag>
    <title>Exception in Rails 2.3.2 when using :group</title>
    <updated-at type="datetime">2009-04-21T15:30:23+02:00</updated-at>
    <user-id type="integer">34931</user-id>
    <user-name>Paco Benavent</user-name>
    <creator-name>Paco Benavent</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/268</url>
    <original-body>Using will_paginate-2.3.8 with Rails 2.3.2 raises an exception when using :group 

Example:

@@@ ruby
 User.paginate :all, :finder =&gt; 'count', :group =&gt; 'country', :page =&gt; 1
@@@

    TypeError: can't convert ActiveSupport::OrderedHash into Array
	from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:135:in `replace'
	from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:135:in `replace'
	from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:82:in `paginate'
	from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:87:in `create'
	from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:76:in `paginate'
	from (irb):5

This is because in Rails 2.3.2, OrderedHash changed from being a subclass of Array to a subclass of Hash.</original-body>
    <latest-body>Using will_paginate-2.3.8 with Rails 2.3.2 raises an exception when using :group 

Example:

@@@ ruby
 User.paginate :all, :finder =&gt; 'count', :group =&gt; 'country', :page =&gt; 1
@@@

    TypeError: can't convert ActiveSupport::OrderedHash into Array
	from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:135:in `replace'
	from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:135:in `replace'
	from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:82:in `paginate'
	from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:87:in `create'
	from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:76:in `paginate'
	from (irb):5

This is because in Rails 2.3.2, OrderedHash changed from being a subclass of Array to a subclass of Hash.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Using will_paginate-2.3.8 with Rails 2.3.2 raises an exception
when using :group&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
 User.paginate :all, :finder =&amp;gt; 'count', :group =&amp;gt; 'country', :page =&amp;gt; 1
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;
&lt;code&gt;TypeError: can't convert ActiveSupport::OrderedHash into Array
from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:135:in `replace'
from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:135:in `replace'
from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:82:in `paginate'
from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:87:in `create'
from /usr/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:76:in `paginate'
from (irb):5
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;This is because in Rails 2.3.2, OrderedHash changed from being a
subclass of Array to a subclass of Hash.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">2</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2009-03-31T16:07:40+02:00</created-at>
    <creator-id type="integer">35954</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">266</number>
    <permalink>rendering-pagination-via-ajax-causes-the-links-to-point-to-ajax-method</permalink>
    <priority type="integer">118</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>invalid</state>
    <tag>ajax bug controller link method</tag>
    <title>Rendering pagination via Ajax causes the links to point to ajax method</title>
    <updated-at type="datetime">2009-04-01T12:02:40+02:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>Michael Larkin</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/266</url>
    <original-body>I use will_paginate in my application to page using non-ajaxy requests.  However, the delete method in my grid is ajaxy, and replaces the entire grid (including pagination links) when an item is deleted.

However, the pagination links no longer point to the index method, but instead to the delete, which is incorrect.

For example:

/promotions?page=2  is what it should be
/promotions/:id/delete?page=2 is what it ends up being, which is obviously impossible because the object was just deleted so the route is not valid.</original-body>
    <latest-body>I use will_paginate in my application to page using non-ajaxy requests.  However, the delete method in my grid is ajaxy, and replaces the entire grid (including pagination links) when an item is deleted.

However, the pagination links no longer point to the index method, but instead to the delete, which is incorrect.

For example:

/promotions?page=2  is what it should be
/promotions/:id/delete?page=2 is what it ends up being, which is obviously impossible because the object was just deleted so the route is not valid.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;I use will_paginate in my application to page using non-ajaxy
requests. However, the delete method in my grid is ajaxy, and
replaces the entire grid (including pagination links) when an item
is deleted.&lt;/p&gt;
&lt;p&gt;However, the pagination links no longer point to the index
method, but instead to the delete, which is incorrect.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;p&gt;/promotions?page=2 is what it should be
/promotions/:id/delete?page=2 is what it ends up being, which is
obviously impossible because the object was just deleted so the
route is not valid.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2009-01-16T20:51:32+01:00</created-at>
    <creator-id type="integer">16360</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">261</number>
    <permalink>has_many-through-uniq-generates-invalid-sql</permalink>
    <priority type="integer">113</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>invalid</state>
    <tag>bug has_many named_scope through</tag>
    <title>has_many through uniq generates invalid sql</title>
    <updated-at type="datetime">2009-03-25T12:29:03+01:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>Chad</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/261</url>
    <original-body>@@@ ruby
has_many :uniq_replies, :source =&gt; :replies, :through =&gt; :topics, :uniq =&gt; true
@@@
pagination generates invalid sql.

from test/console
@@@
&gt;&gt; Project.first.uniq_replies.paginate(:page =&gt; 1, :per_page =&gt; 1)
  Project Load (0.3ms)   SELECT * FROM &quot;projects&quot; LIMIT 1
  Reply Load (0.8ms)   SELECT DISTINCT &quot;replies&quot;.* FROM &quot;replies&quot; INNER JOIN topics ON replies.topic_id = topics.id WHERE ((&quot;topics&quot;.project_id = 1)) LIMIT 1 OFFSET 0
  SQL (0.0ms)   SQLite3::SQLException: near &quot;*&quot;: syntax error: SELECT count(DISTINCT &quot;replies&quot;.*) AS count_distinct_replies_all FROM &quot;replies&quot; INNER JOIN topics ON replies.topic_id = topics.id WHERE ((&quot;topics&quot;.project_id = 1)) 
ActiveRecord::StatementInvalid: SQLite3::SQLException: near &quot;*&quot;: syntax error: SELECT count(DISTINCT &quot;replies&quot;.*) AS count_distinct_replies_all FROM &quot;replies&quot;  INNER JOIN topics ON replies.topic_id = topics.id    WHERE ((&quot;topics&quot;.project_id = 1))
@@@

I think the SQL should read:
@@@ SQL
SELECT DISTINCT &quot;replies&quot;.id ...
@@@</original-body>
    <latest-body>@@@ ruby
has_many :uniq_replies, :source =&gt; :replies, :through =&gt; :topics, :uniq =&gt; true
@@@
pagination generates invalid sql.

from test/console
@@@
&gt;&gt; Project.first.uniq_replies.paginate(:page =&gt; 1, :per_page =&gt; 1)
  Project Load (0.3ms)   SELECT * FROM &quot;projects&quot; LIMIT 1
  Reply Load (0.8ms)   SELECT DISTINCT &quot;replies&quot;.* FROM &quot;replies&quot; INNER JOIN topics ON replies.topic_id = topics.id WHERE ((&quot;topics&quot;.project_id = 1)) LIMIT 1 OFFSET 0
  SQL (0.0ms)   SQLite3::SQLException: near &quot;*&quot;: syntax error: SELECT count(DISTINCT &quot;replies&quot;.*) AS count_distinct_replies_all FROM &quot;replies&quot; INNER JOIN topics ON replies.topic_id = topics.id WHERE ((&quot;topics&quot;.project_id = 1)) 
ActiveRecord::StatementInvalid: SQLite3::SQLException: near &quot;*&quot;: syntax error: SELECT count(DISTINCT &quot;replies&quot;.*) AS count_distinct_replies_all FROM &quot;replies&quot;  INNER JOIN topics ON replies.topic_id = topics.id    WHERE ((&quot;topics&quot;.project_id = 1))
@@@

I think the SQL should read:
@@@ SQL
SELECT DISTINCT &quot;replies&quot;.id ...
@@@</latest-body>
    <original-body-html>&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
has_many :uniq_replies, :source =&amp;gt; :replies, :through =&amp;gt; :topics, :uniq =&amp;gt; true
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;pagination generates invalid sql.&lt;/p&gt;
&lt;p&gt;from test/console&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
&amp;gt;&amp;gt; Project.first.uniq_replies.paginate(:page =&amp;gt; 1, :per_page =&amp;gt; 1)
  Project Load (0.3ms)   SELECT * FROM &amp;quot;projects&amp;quot; LIMIT 1
  Reply Load (0.8ms)   SELECT DISTINCT &amp;quot;replies&amp;quot;.* FROM &amp;quot;replies&amp;quot; INNER JOIN topics ON replies.topic_id = topics.id WHERE ((&amp;quot;topics&amp;quot;.project_id = 1)) LIMIT 1 OFFSET 0
  SQL (0.0ms)   SQLite3::SQLException: near &amp;quot;*&amp;quot;: syntax error: SELECT count(DISTINCT &amp;quot;replies&amp;quot;.*) AS count_distinct_replies_all FROM &amp;quot;replies&amp;quot; INNER JOIN topics ON replies.topic_id = topics.id WHERE ((&amp;quot;topics&amp;quot;.project_id = 1)) 
ActiveRecord::StatementInvalid: SQLite3::SQLException: near &amp;quot;*&amp;quot;: syntax error: SELECT count(DISTINCT &amp;quot;replies&amp;quot;.*) AS count_distinct_replies_all FROM &amp;quot;replies&amp;quot;  INNER JOIN topics ON replies.topic_id = topics.id    WHERE ((&amp;quot;topics&amp;quot;.project_id = 1))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I think the SQL should read: @@@ SQL SELECT DISTINCT
&quot;replies&quot;.id ...&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2009-03-21T22:01:03+01:00</created-at>
    <creator-id type="integer">46326</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">265</number>
    <permalink>incorrect-counts-in-rails-23</permalink>
    <priority type="integer">117</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>invalid</state>
    <tag nil="true"></tag>
    <title>Incorrect counts in rails 2.3 </title>
    <updated-at type="datetime">2009-03-21T23:36:24+01:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>Diegorv</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/265</url>
    <original-body>I have this code
@@@
def self.completa(estado_id, cidade_id, bairro_id, segmento_id, pagina, limit = 5)
campos_padrao.estado(@estado_uf).cidade(@cidade_id).bairro(bairro_id).segmento(@segmento_id).joins.paginate(:per_page =&gt; limit, :page =&gt; pagina)
  end


named_scope :campos_padrao, lambda { |*args| 
    {
      :select=&gt; (args.first ||
                &quot;anuncios.codcli,
                 anuncios.codseg,
                 anuncios.nomefanta,
                 anuncios.irmao,
                 anuncios.endereco,
                 anuncios.num,
                 anuncios.complemento,
                 anuncios.cep,
                 anuncios.bairro,
                 anuncios.cidade,
                 anuncios.uf,
                 anuncios.fone,
                 anuncios.fax,
                 anuncios.email,
                 anuncios.site,
                 anuncios.descricao,
                 anuncios.fig_anuncio,
                 anuncios.contrato,
                 anuncios.uf_anunciar,
                 anuncios.permalink,
                 cidades.cidade as cidade_nome,
                 estados.nome as estado_nome,
                 segmentos.nome as segmento
                  &quot;) }
    }

named_scope :segmento, lambda { |*args|
    if (args.first != &quot;todos_segmentos&quot;)
      { :conditions =&gt; [&quot;anuncios.codseg = ?&quot;, args.first]  }
    else
      {  }
    end
  }
  
  named_scope :estado,  lambda { |*args| 
    {
      :conditions =&gt; [&quot;anuncios.uf = ?&quot;, args.first]
    }
  }
  
  named_scope :cidade,  lambda { |*args|
    if (args.first != &quot;todas_cidades&quot;)
      { :conditions =&gt; [&quot;anuncios.cidade = ?&quot;, args.first]  }
    else
      {  }
    end
  }
  
  named_scope :bairro, lambda { |*args|
    if (args.first != &quot;todos_bairros&quot;)
      { :conditions =&gt; [&quot;anuncios.bairro LIKE ?&quot;, &quot;%#{args.first}%&quot;]  }
    else
      {  }
    end
  }

@@@

I get this error.

ctiveRecord::StatementInvalid (Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
                 anuncios.codseg,
                 anuncios.nomefanta,
        ' at line 1: SELECT count(anuncios.codcli,
                 anuncios.codseg,
                 anuncios.nomefanta,
                 anuncios.irmao,
                 anuncios.endereco,
                 anuncios.num,
                 anuncios.complemento,
                 anuncios.cep,
                 anuncios.bairro,
                 anuncios.cidade,
                 anuncios.uf,
                 anuncios.fone,
                 anuncios.fax,
                 anuncios.email,
                 anuncios.site,
                 anuncios.descricao,
                 anuncios.fig_anuncio,
                 anuncios.contrato,
                 anuncios.uf_anunciar,
                 anuncios.permalink,
                 cidades.cidade as cidade_nome,
                 estados.nome as estado_nome,
                 segmentos.nome as segmento
                  ) AS count_anuncios_codcli_anuncios_codseg_anuncios_nomefanta_anuncios_irmao_anuncios_endereco_anuncios_num_anuncios_complemento_anuncios_cep_anuncios_bairro_anuncios_cidade_anuncios_uf_anuncios_fone_anuncios_fax_anuncios_email_anuncios_site_anuncios_descricao FROM `anuncios`   INNER JOIN `estados` ON `estados`.uf = `anuncios`.uf  INNER JOIN `cidades` ON `cidades`.codcid = `anuncios`.cidade  INNER JOIN `segmentos` ON `segmentos`.codseg = `anuncios`.codseg  WHERE (anuncios.uf = 'AC') ):
  /Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:223:in `wp_count'
  /Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:235:in `call'
  /Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:235:in `wp_count'
  /Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:85:in `paginate'
  /Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:87:in `create'
  /Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:76:in `paginate'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'</original-body>
    <latest-body>I have this code
@@@
def self.completa(estado_id, cidade_id, bairro_id, segmento_id, pagina, limit = 5)
campos_padrao.estado(@estado_uf).cidade(@cidade_id).bairro(bairro_id).segmento(@segmento_id).joins.paginate(:per_page =&gt; limit, :page =&gt; pagina)
  end


named_scope :campos_padrao, lambda { |*args| 
    {
      :select=&gt; (args.first ||
                &quot;anuncios.codcli,
                 anuncios.codseg,
                 anuncios.nomefanta,
                 anuncios.irmao,
                 anuncios.endereco,
                 anuncios.num,
                 anuncios.complemento,
                 anuncios.cep,
                 anuncios.bairro,
                 anuncios.cidade,
                 anuncios.uf,
                 anuncios.fone,
                 anuncios.fax,
                 anuncios.email,
                 anuncios.site,
                 anuncios.descricao,
                 anuncios.fig_anuncio,
                 anuncios.contrato,
                 anuncios.uf_anunciar,
                 anuncios.permalink,
                 cidades.cidade as cidade_nome,
                 estados.nome as estado_nome,
                 segmentos.nome as segmento
                  &quot;) }
    }

named_scope :segmento, lambda { |*args|
    if (args.first != &quot;todos_segmentos&quot;)
      { :conditions =&gt; [&quot;anuncios.codseg = ?&quot;, args.first]  }
    else
      {  }
    end
  }
  
  named_scope :estado,  lambda { |*args| 
    {
      :conditions =&gt; [&quot;anuncios.uf = ?&quot;, args.first]
    }
  }
  
  named_scope :cidade,  lambda { |*args|
    if (args.first != &quot;todas_cidades&quot;)
      { :conditions =&gt; [&quot;anuncios.cidade = ?&quot;, args.first]  }
    else
      {  }
    end
  }
  
  named_scope :bairro, lambda { |*args|
    if (args.first != &quot;todos_bairros&quot;)
      { :conditions =&gt; [&quot;anuncios.bairro LIKE ?&quot;, &quot;%#{args.first}%&quot;]  }
    else
      {  }
    end
  }

@@@

I get this error.

ctiveRecord::StatementInvalid (Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
                 anuncios.codseg,
                 anuncios.nomefanta,
        ' at line 1: SELECT count(anuncios.codcli,
                 anuncios.codseg,
                 anuncios.nomefanta,
                 anuncios.irmao,
                 anuncios.endereco,
                 anuncios.num,
                 anuncios.complemento,
                 anuncios.cep,
                 anuncios.bairro,
                 anuncios.cidade,
                 anuncios.uf,
                 anuncios.fone,
                 anuncios.fax,
                 anuncios.email,
                 anuncios.site,
                 anuncios.descricao,
                 anuncios.fig_anuncio,
                 anuncios.contrato,
                 anuncios.uf_anunciar,
                 anuncios.permalink,
                 cidades.cidade as cidade_nome,
                 estados.nome as estado_nome,
                 segmentos.nome as segmento
                  ) AS count_anuncios_codcli_anuncios_codseg_anuncios_nomefanta_anuncios_irmao_anuncios_endereco_anuncios_num_anuncios_complemento_anuncios_cep_anuncios_bairro_anuncios_cidade_anuncios_uf_anuncios_fone_anuncios_fax_anuncios_email_anuncios_site_anuncios_descricao FROM `anuncios`   INNER JOIN `estados` ON `estados`.uf = `anuncios`.uf  INNER JOIN `cidades` ON `cidades`.codcid = `anuncios`.cidade  INNER JOIN `segmentos` ON `segmentos`.codseg = `anuncios`.codseg  WHERE (anuncios.uf = 'AC') ):
  /Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:223:in `wp_count'
  /Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:235:in `call'
  /Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:235:in `wp_count'
  /Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:85:in `paginate'
  /Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:87:in `create'
  /Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:76:in `paginate'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'
  (__DELEGATION__):2:in `__send__'
  (__DELEGATION__):2:in `with_scope'</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;I have this code&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
def self.completa(estado_id, cidade_id, bairro_id, segmento_id, pagina, limit = 5)
campos_padrao.estado(@estado_uf).cidade(@cidade_id).bairro(bairro_id).segmento(@segmento_id).joins.paginate(:per_page =&amp;gt; limit, :page =&amp;gt; pagina)
  end


named_scope :campos_padrao, lambda { |*args| 
    {
      :select=&amp;gt; (args.first ||
                &amp;quot;anuncios.codcli,
                 anuncios.codseg,
                 anuncios.nomefanta,
                 anuncios.irmao,
                 anuncios.endereco,
                 anuncios.num,
                 anuncios.complemento,
                 anuncios.cep,
                 anuncios.bairro,
                 anuncios.cidade,
                 anuncios.uf,
                 anuncios.fone,
                 anuncios.fax,
                 anuncios.email,
                 anuncios.site,
                 anuncios.descricao,
                 anuncios.fig_anuncio,
                 anuncios.contrato,
                 anuncios.uf_anunciar,
                 anuncios.permalink,
                 cidades.cidade as cidade_nome,
                 estados.nome as estado_nome,
                 segmentos.nome as segmento
                  &amp;quot;) }
    }

named_scope :segmento, lambda { |*args|
    if (args.first != &amp;quot;todos_segmentos&amp;quot;)
      { :conditions =&amp;gt; [&amp;quot;anuncios.codseg = ?&amp;quot;, args.first]  }
    else
      {  }
    end
  }
  
  named_scope :estado,  lambda { |*args| 
    {
      :conditions =&amp;gt; [&amp;quot;anuncios.uf = ?&amp;quot;, args.first]
    }
  }
  
  named_scope :cidade,  lambda { |*args|
    if (args.first != &amp;quot;todas_cidades&amp;quot;)
      { :conditions =&amp;gt; [&amp;quot;anuncios.cidade = ?&amp;quot;, args.first]  }
    else
      {  }
    end
  }
  
  named_scope :bairro, lambda { |*args|
    if (args.first != &amp;quot;todos_bairros&amp;quot;)
      { :conditions =&amp;gt; [&amp;quot;anuncios.bairro LIKE ?&amp;quot;, &amp;quot;%#{args.first}%&amp;quot;]  }
    else
      {  }
    end
  }

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I get this error.&lt;/p&gt;
&lt;p&gt;ctiveRecord::StatementInvalid (Mysql::Error: You have an error
in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near '&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;             anuncios.codseg,
             anuncios.nomefanta,
    ' at line 1: SELECT count(anuncios.codcli,
             anuncios.codseg,
             anuncios.nomefanta,
             anuncios.irmao,
             anuncios.endereco,
             anuncios.num,
             anuncios.complemento,
             anuncios.cep,
             anuncios.bairro,
             anuncios.cidade,
             anuncios.uf,
             anuncios.fone,
             anuncios.fax,
             anuncios.email,
             anuncios.site,
             anuncios.descricao,
             anuncios.fig_anuncio,
             anuncios.contrato,
             anuncios.uf_anunciar,
             anuncios.permalink,
             cidades.cidade as cidade_nome,
             estados.nome as estado_nome,
             segmentos.nome as segmento
              ) AS count_anuncios_codcli_anuncios_codseg_anuncios_nomefanta_anuncios_irmao_anuncios_endereco_anuncios_num_anuncios_complemento_anuncios_cep_anuncios_bairro_anuncios_cidade_anuncios_uf_anuncios_fone_anuncios_fax_anuncios_email_anuncios_site_anuncios_descricao FROM `anuncios`   INNER JOIN `estados` ON `estados`.uf = `anuncios`.uf  INNER JOIN `cidades` ON `cidades`.codcid = `anuncios`.cidade  INNER JOIN `segmentos` ON `segmentos`.codseg = `anuncios`.codseg  WHERE (anuncios.uf = 'AC') ):
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;
/Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:223:in
&lt;code&gt;wp_count'
/Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:235:in&lt;/code&gt;call'
/Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:235:in
&lt;code&gt;wp_count'
/Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:85:in&lt;/code&gt;paginate'
/Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/collection.rb:87:in
&lt;code&gt;create'
/Library/Ruby/Gems/1.8/gems/mislav-will_paginate-2.3.8/lib/will_paginate/finder.rb:76:in&lt;/code&gt;paginate'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'
(&lt;strong&gt;DELEGATION&lt;/strong&gt;):2:in &lt;code&gt;__send__'
(__DELEGATION__):2:in&lt;/code&gt;with_scope'&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2008-05-14T11:06:20+02:00</created-at>
    <creator-id type="integer">18232</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">219</number>
    <permalink>activerecord-statementinvalid-when-using-custom-select-and-having</permalink>
    <priority type="integer">88</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>invalid</state>
    <tag>will_paginate</tag>
    <title> ActiveRecord::StatementInvalid when using custom select and having</title>
    <updated-at type="datetime">2009-03-13T23:17:19+01:00</updated-at>
    <user-id type="integer">23331</user-id>
    <user-name>Greg</user-name>
    <creator-name>asherwood</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/219</url>
    <original-body>When using a custom select statement like the one provided in the following example 

@results =  Page.paginate(:all,
                        :select =&gt; &quot;pages.*, ((ACOS(SIN(#{location.geom.y} * PI() / 180) * SIN(Y(GeomFromText( AsText(try_outs.geom))) * PI() / 180) + COS(#{location.geom.y} * PI() / 180) * COS(Y(GeomFromText( AsText(try_outs.geom))) * PI() / 180) * COS((#{location.geom.x} - X(GeomFromText( AsText(try_outs.geom)))) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS distance &quot;,
                        :group =&gt; 'pages.id HAVING distance &lt; 300',
                        :page =&gt; params[:page], 
                        :per_page =&gt; 5)

An error is thrown due to will_paginate doing this
SELECT count(*) AS count_all, pages.id HAVING distance &lt; 300 AS pages_id_having_distance_300</original-body>
    <latest-body>When using a custom select statement like the one provided in the following example 

@results =  Page.paginate(:all,
                        :select =&gt; &quot;pages.*, ((ACOS(SIN(#{location.geom.y} * PI() / 180) * SIN(Y(GeomFromText( AsText(try_outs.geom))) * PI() / 180) + COS(#{location.geom.y} * PI() / 180) * COS(Y(GeomFromText( AsText(try_outs.geom))) * PI() / 180) * COS((#{location.geom.x} - X(GeomFromText( AsText(try_outs.geom)))) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS distance &quot;,
                        :group =&gt; 'pages.id HAVING distance &lt; 300',
                        :page =&gt; params[:page], 
                        :per_page =&gt; 5)

An error is thrown due to will_paginate doing this
SELECT count(*) AS count_all, pages.id HAVING distance &lt; 300 AS pages_id_having_distance_300</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;
When using a custom select statement like the one provided in the following example
&lt;/p&gt;&lt;p&gt;
@results =  Page.paginate(:all,
&lt;/p&gt;&lt;p&gt;
:select =&gt; &quot;pages.*, ((ACOS(SIN(#{location.geom.y} * PI() / 180) * SIN(Y(GeomFromText( AsText(try_outs.geom))) * PI() / 180) + COS(#{location.geom.y} * PI() / 180) * COS(Y(GeomFromText( AsText(try_outs.geom))) * PI() / 180) * COS((#{location.geom.x} - X(GeomFromText( AsText(try_outs.geom)))) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS distance &quot;,
&lt;/p&gt;&lt;p&gt;
:group =&gt; 'pages.id HAVING distance &amp;lt; 300',
&lt;/p&gt;&lt;p&gt;
:page =&gt; params[:page],
&lt;/p&gt;&lt;p&gt;
:per_page =&gt; 5)
&lt;/p&gt;&lt;p&gt;
An error is thrown due to will_paginate doing this
&lt;/p&gt;&lt;p&gt;
SELECT count(*) AS count_all, pages.id HAVING distance &amp;lt; 300 AS pages_id_having_distance_300
&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-03-03T19:07:55+01:00</created-at>
    <creator-id type="integer">45858</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">264</number>
    <permalink>incorrect-counts-when-using-rails-23-having-option-and-scopes</permalink>
    <priority type="integer">116</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>open</state>
    <tag nil="true"></tag>
    <title>Incorrect counts when using rails 2.3 :having option and scopes</title>
    <updated-at type="datetime">2009-03-03T19:10:44+01:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>Blane Dabney</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/264</url>
    <original-body>I'm using rails 2.3 and have a named_scope that uses the :having option to filter results based on joined aggregate data. When using will_paginate with this, the :having (and :group) options from the scope are not passed through to the count method, so the page count it calculates is inaccurate. I have attached the patch I made to resolve this. It probably needs some work but it resolved my immediate need. It basically ensures that the :having and :group options are pulled from the scope and ONLY if they weren't explicity defined when calling paginate.</original-body>
    <latest-body>I'm using rails 2.3 and have a named_scope that uses the :having option to filter results based on joined aggregate data. When using will_paginate with this, the :having (and :group) options from the scope are not passed through to the count method, so the page count it calculates is inaccurate. I have attached the patch I made to resolve this. It probably needs some work but it resolved my immediate need. It basically ensures that the :having and :group options are pulled from the scope and ONLY if they weren't explicity defined when calling paginate.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;I'm using rails 2.3 and have a named_scope that uses the :having
option to filter results based on joined aggregate data. When using
will_paginate with this, the :having (and :group) options from the
scope are not passed through to the count method, so the page count
it calculates is inaccurate. I have attached the patch I made to
resolve this. It probably needs some work but it resolved my
immediate need. It basically ensures that the :having and :group
options are pulled from the scope and ONLY if they weren't
explicity defined when calling paginate.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-02-11T18:35:48+01:00</created-at>
    <creator-id type="integer">47072</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">263</number>
    <permalink>wrong-count-results</permalink>
    <priority type="integer">115</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>count</tag>
    <title>wrong count results</title>
    <updated-at type="datetime">2009-02-12T09:43:29+01:00</updated-at>
    <user-id type="integer">47072</user-id>
    <user-name>friofool</user-name>
    <creator-name>friofool</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/263</url>
    <original-body>hi,

this is my log :

SQL (3.1ms)   SELECT count(*) AS count_all, mifo.mod_icom_option_id,mip.id AS mifo_mod_icom_option_id_mip_id FROM `mod_icom_files_options` as mifo inner join mod_icom_prods as mip on (mifo.mod_icom_prod_id = mip.id) inner join mod_icom_marque_prods as mimp on (mip.id = mimp.mod_icom_prod_id) where mip.visibilite_prod = 1 AND mip.statut_promo !='destockage' and mifo.valide = 1 and mip.visibilite_prod = 1 and mimp.mod_icom_marque_id = 45 GROUP BY mifo.mod_icom_option_id,mip.id 

If i tun this query in sql database client i found 28 results but the count method return 18 records (i add a logger in the wp_count method).


I set the :per_page =&gt; 9, and the view method display 2 pages.

But if i try to change manually the page number parameter in the url to 3, the helper show me 4 pages who is the correct value.

Is there a bug ?</original-body>
    <latest-body>hi,

this is my log :

SQL (3.1ms)   SELECT count(*) AS count_all, mifo.mod_icom_option_id,mip.id AS mifo_mod_icom_option_id_mip_id FROM `mod_icom_files_options` as mifo inner join mod_icom_prods as mip on (mifo.mod_icom_prod_id = mip.id) inner join mod_icom_marque_prods as mimp on (mip.id = mimp.mod_icom_prod_id) where mip.visibilite_prod = 1 AND mip.statut_promo !='destockage' and mifo.valide = 1 and mip.visibilite_prod = 1 and mimp.mod_icom_marque_id = 45 GROUP BY mifo.mod_icom_option_id,mip.id 

If i tun this query in sql database client i found 28 results but the count method return 18 records (i add a logger in the wp_count method).


I set the :per_page =&gt; 9, and the view method display 2 pages.

But if i try to change manually the page number parameter in the url to 3, the helper show me 4 pages who is the correct value.

Is there a bug ?</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;hi,&lt;/p&gt;
&lt;p&gt;this is my log :&lt;/p&gt;
&lt;p&gt;SQL (3.1ms) SELECT count(*) AS count_all,
mifo.mod_icom_option_id,mip.id AS mifo_mod_icom_option_id_mip_id
FROM &lt;code&gt;mod_icom_files_options&lt;/code&gt; as mifo inner join
mod_icom_prods as mip on (mifo.mod_icom_prod_id = mip.id) inner
join mod_icom_marque_prods as mimp on (mip.id =
mimp.mod_icom_prod_id) where mip.visibilite_prod = 1 AND
mip.statut_promo !='destockage' and mifo.valide = 1 and
mip.visibilite_prod = 1 and mimp.mod_icom_marque_id = 45 GROUP BY
mifo.mod_icom_option_id,mip.id&lt;/p&gt;
&lt;p&gt;If i tun this query in sql database client i found 28 results
but the count method return 18 records (i add a logger in the
wp_count method).&lt;/p&gt;
&lt;p&gt;I set the :per_page =&amp;gt; 9, and the view method display 2
pages.&lt;/p&gt;
&lt;p&gt;But if i try to change manually the page number parameter in the
url to 3, the helper show me 4 pages who is the correct value.&lt;/p&gt;
&lt;p&gt;Is there a bug ?&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2008-12-10T03:37:55+01:00</created-at>
    <creator-id type="integer">40294</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">255</number>
    <permalink>paginate-very-slow-on-large-queries-with-group</permalink>
    <priority type="integer">107</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>resolved</state>
    <tag nil="true"></tag>
    <title>paginate very slow on large queries with :group</title>
    <updated-at type="datetime">2009-02-06T01:32:15+01:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>Michael Ragalie</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/255</url>
    <original-body>In finder.rb, wp_count() passes off to count() in order to figure out how many total results exist. When :group is specified, count() uses execute_grouped_calculation() in ActiveRecord::Calculations, which calls ActiveSupport::OrderedHash[]= . ActiveSupport::OrderedHash[]= calls assoc() on the its internal Array, which compares the value passed to assoc() to the first value of each array within its internal Array. As a result, for my application, which has a total of 2,895 matching rows, a total of 4,189,065 == comparisons are made in the course of determining the number of rows.

This is obviously very slow. Is there be a faster way to calculate the number of rows for queries with :group?</original-body>
    <latest-body>In finder.rb, wp_count() passes off to count() in order to figure out how many total results exist. When :group is specified, count() uses execute_grouped_calculation() in ActiveRecord::Calculations, which calls ActiveSupport::OrderedHash[]= . ActiveSupport::OrderedHash[]= calls assoc() on the its internal Array, which compares the value passed to assoc() to the first value of each array within its internal Array. As a result, for my application, which has a total of 2,895 matching rows, a total of 4,189,065 == comparisons are made in the course of determining the number of rows.

This is obviously very slow. Is there be a faster way to calculate the number of rows for queries with :group?</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;In finder.rb, wp_count() passes off to count() in order to
figure out how many total results exist. When :group is specified,
count() uses execute_grouped_calculation() in
ActiveRecord::Calculations, which calls
ActiveSupport::OrderedHash[]= . ActiveSupport::OrderedHash[]= calls
assoc() on the its internal Array, which compares the value passed
to assoc() to the first value of each array within its internal
Array. As a result, for my application, which has a total of 2,895
matching rows, a total of 4,189,065 == comparisons are made in the
course of determining the number of rows.&lt;/p&gt;
&lt;p&gt;This is obviously very slow. Is there be a faster way to
calculate the number of rows for queries with :group?&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-01-29T08:10:02+01:00</created-at>
    <creator-id type="integer">15518</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">262</number>
    <permalink>behavior-of-view-helper-is-incorrect-if-url-includes</permalink>
    <priority type="integer">114</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>open</state>
    <tag>html url view will_paginate</tag>
    <title>Behavior of view helper is incorrect if URL includes &quot;@&quot;</title>
    <updated-at type="datetime">2009-01-30T08:17:10+01:00</updated-at>
    <user-id type="integer">15518</user-id>
    <user-name>Anton Ageev</user-name>
    <creator-name>Anton Ageev</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/262</url>
    <original-body>Given:
* Rails 2.1.2
* will_paginate 2.3.6

config/routes.rb:
@@@ ruby
ActionController::Routing::Routes.draw do |map|
  RE_USER_LOGIN = /[^\/]+/

  map.with_options :controller =&gt; &quot;user_blogs&quot;, :action =&gt; &quot;index&quot; do |r|
    r.connect &quot;blogs/:user_login/pages/:page&quot;, :requirements =&gt; { :user_login =&gt; RE_USER_LOGIN }
    r.connect &quot;blogs/:user_login&quot;, :requirements =&gt; { :user_login =&gt; RE_USER_LOGIN }
  end
  ....
end
@@@

app/views/user_blogs/index.html.erb:
@@@
  ...
  &lt;%= will_paginate @news %&gt;
  ...
@@@

I get page links &quot;/blogs/2Andrex/pages/@&quot;, &quot;/blogs/3Andrex/pages/@&quot; when I visited &quot;/blogs/@Andrex&quot;.

The routing works fine:
@@@
$ ./script/console
&gt;&gt; irb ActionController::Routing::Routes
irb: warn: can't alias context from irb_context.

&gt;&gt; recognize_path &quot;/blogs/@Andrex/pages/2&quot;
=&gt; {:user_login=&gt;&quot;@Andrex&quot;, :controller=&gt;&quot;user_blogs&quot;, :page=&gt;&quot;2&quot;, :action=&gt;&quot;index&quot;}

&gt;&gt; generate :user_login=&gt;&quot;@Andrex&quot;, :controller=&gt;&quot;user_blogs&quot;, :page=&gt;&quot;2&quot;, :action=&gt;&quot;index&quot;
=&gt; &quot;/blogs/@Andrex/pages/2&quot;
@@@</original-body>
    <latest-body>Given:
* Rails 2.1.2
* will_paginate 2.3.6

config/routes.rb:
@@@ ruby
ActionController::Routing::Routes.draw do |map|
  RE_USER_LOGIN = /[^\/]+/

  map.with_options :controller =&gt; &quot;user_blogs&quot;, :action =&gt; &quot;index&quot; do |r|
    r.connect &quot;blogs/:user_login/pages/:page&quot;, :requirements =&gt; { :user_login =&gt; RE_USER_LOGIN }
    r.connect &quot;blogs/:user_login&quot;, :requirements =&gt; { :user_login =&gt; RE_USER_LOGIN }
  end
  ....
end
@@@

app/views/user_blogs/index.html.erb:
@@@
  ...
  &lt;%= will_paginate @news %&gt;
  ...
@@@

I get page links &quot;/blogs/2Andrex/pages/@&quot;, &quot;/blogs/3Andrex/pages/@&quot; when I visited &quot;/blogs/@Andrex&quot;.

The routing works fine:
@@@
$ ./script/console
&gt;&gt; irb ActionController::Routing::Routes
irb: warn: can't alias context from irb_context.

&gt;&gt; recognize_path &quot;/blogs/@Andrex/pages/2&quot;
=&gt; {:user_login=&gt;&quot;@Andrex&quot;, :controller=&gt;&quot;user_blogs&quot;, :page=&gt;&quot;2&quot;, :action=&gt;&quot;index&quot;}

&gt;&gt; generate :user_login=&gt;&quot;@Andrex&quot;, :controller=&gt;&quot;user_blogs&quot;, :page=&gt;&quot;2&quot;, :action=&gt;&quot;index&quot;
=&gt; &quot;/blogs/@Andrex/pages/2&quot;
@@@</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Given: * Rails 2.1.2 * will_paginate 2.3.6&lt;/p&gt;
&lt;p&gt;config/routes.rb:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
ActionController::Routing::Routes.draw do |map|
  RE_USER_LOGIN = /[^\/]+/

  map.with_options :controller =&amp;gt; &amp;quot;user_blogs&amp;quot;, :action =&amp;gt; &amp;quot;index&amp;quot; do |r|
    r.connect &amp;quot;blogs/:user_login/pages/:page&amp;quot;, :requirements =&amp;gt; { :user_login =&amp;gt; RE_USER_LOGIN }
    r.connect &amp;quot;blogs/:user_login&amp;quot;, :requirements =&amp;gt; { :user_login =&amp;gt; RE_USER_LOGIN }
  end
  ....
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;app/views/user_blogs/index.html.erb:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  ...
  &amp;lt;%= will_paginate @news %&amp;gt;
  ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I get page links &quot;/blogs/2Andrex/pages/@&quot;,
&quot;/blogs/3Andrex/pages/@&quot; when I visited &quot;/blogs/@Andrex&quot;.&lt;/p&gt;
&lt;p&gt;The routing works fine:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
$ ./script/console
&amp;gt;&amp;gt; irb ActionController::Routing::Routes
irb: warn: can't alias context from irb_context.

&amp;gt;&amp;gt; recognize_path &amp;quot;/blogs/@Andrex/pages/2&amp;quot;
=&amp;gt; {:user_login=&amp;gt;&amp;quot;@Andrex&amp;quot;, :controller=&amp;gt;&amp;quot;user_blogs&amp;quot;, :page=&amp;gt;&amp;quot;2&amp;quot;, :action=&amp;gt;&amp;quot;index&amp;quot;}

&amp;gt;&amp;gt; generate :user_login=&amp;gt;&amp;quot;@Andrex&amp;quot;, :controller=&amp;gt;&amp;quot;user_blogs&amp;quot;, :page=&amp;gt;&amp;quot;2&amp;quot;, :action=&amp;gt;&amp;quot;index&amp;quot;
=&amp;gt; &amp;quot;/blogs/@Andrex/pages/2&amp;quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2009-01-14T19:33:35+01:00</created-at>
    <creator-id type="integer">41565</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">260</number>
    <permalink>incorrect-set-of-records-returned-when-using-order-on-a-field-with-little-variation</permalink>
    <priority type="integer">112</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>resolved</state>
    <tag>id mssql order sort</tag>
    <title>incorrect set of records returned when using order on a field with little variation</title>
    <updated-at type="datetime">2009-01-16T12:13:21+01:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>ReggieB</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/260</url>
    <original-body>I think I have found a bug this time :o) . However, it may be a MS SQL only error as I haven't tested the problem with MySQL.

I have a table of &quot;support cases&quot; and each case can have a status of one of five options (e.g. 'open', 'closed', 'suspended' etc.). If I sort by the case status in a paginated view I get records repeated on different pages and some records don't appear at all. The correct total of records is always shown.

I believe I have found the problem: it is the way will_paginate pulls out the small number of records it needs for a single page view. If you have a page size of 20 and 65 records total, to get the page two records it first pulls out the first 40 records (order DESC), then flips them over (order ASC) and pulls the first 20 records, then flips them over again (order DESC) to present the set of 20 records in the desired order.

This works fine if the field you are sorting on is unique for each record, but falls down if you have a lot of records with the same field value. SQL seems to be inconsistent in the ordering of individual records within one unique field value. 

That is the order of ten records with the status &quot;open&quot; sorted using &quot;order DESC&quot; don't seem to be mirror images of the same records when you do the next &quot;order ASC&quot; step. That is, they may be 1,2,3,4,5,6,7,8,9,10 on the &quot;order DESC&quot; but may well be 10,8,7,3,4,5,1,2,9,6 on next &quot;order ASC&quot;

This results in inconsistency when you reorder the records and remove some at each step.

What seems to fix the problem is if you add a field to the sort that is unique for each record. id is the obvious one.

So 
@@@
SupportCase.paginate(:page =&gt; params[:page],
                :per_page =&gt; 20,
                :order =&gt; &quot;order DESC&quot;
@@@
Results in inconsistent behaviour.

@@@
SupportCase.paginate(:page =&gt; params[:page],
                :per_page =&gt; 20,
                :order =&gt; &quot;order DESC, id DESC&quot;
@@@
Creates the correct results.

I suggest you append &quot;, id DESC&quot; to then end of all order statements unless id is already used in the sort.</original-body>
    <latest-body>I think I have found a bug this time :o) . However, it may be a MS SQL only error as I haven't tested the problem with MySQL.

I have a table of &quot;support cases&quot; and each case can have a status of one of five options (e.g. 'open', 'closed', 'suspended' etc.). If I sort by the case status in a paginated view I get records repeated on different pages and some records don't appear at all. The correct total of records is always shown.

I believe I have found the problem: it is the way will_paginate pulls out the small number of records it needs for a single page view. If you have a page size of 20 and 65 records total, to get the page two records it first pulls out the first 40 records (order DESC), then flips them over (order ASC) and pulls the first 20 records, then flips them over again (order DESC) to present the set of 20 records in the desired order.

This works fine if the field you are sorting on is unique for each record, but falls down if you have a lot of records with the same field value. SQL seems to be inconsistent in the ordering of individual records within one unique field value. 

That is the order of ten records with the status &quot;open&quot; sorted using &quot;order DESC&quot; don't seem to be mirror images of the same records when you do the next &quot;order ASC&quot; step. That is, they may be 1,2,3,4,5,6,7,8,9,10 on the &quot;order DESC&quot; but may well be 10,8,7,3,4,5,1,2,9,6 on next &quot;order ASC&quot;

This results in inconsistency when you reorder the records and remove some at each step.

What seems to fix the problem is if you add a field to the sort that is unique for each record. id is the obvious one.

So 
@@@
SupportCase.paginate(:page =&gt; params[:page],
                :per_page =&gt; 20,
                :order =&gt; &quot;order DESC&quot;
@@@
Results in inconsistent behaviour.

@@@
SupportCase.paginate(:page =&gt; params[:page],
                :per_page =&gt; 20,
                :order =&gt; &quot;order DESC, id DESC&quot;
@@@
Creates the correct results.

I suggest you append &quot;, id DESC&quot; to then end of all order statements unless id is already used in the sort.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;I think I have found a bug this time :o) . However, it may be a
MS SQL only error as I haven't tested the problem with MySQL.&lt;/p&gt;
&lt;p&gt;I have a table of &quot;support cases&quot; and each case can have a
status of one of five options (e.g. 'open', 'closed', 'suspended'
etc.). If I sort by the case status in a paginated view I get
records repeated on different pages and some records don't appear
at all. The correct total of records is always shown.&lt;/p&gt;
&lt;p&gt;I believe I have found the problem: it is the way will_paginate
pulls out the small number of records it needs for a single page
view. If you have a page size of 20 and 65 records total, to get
the page two records it first pulls out the first 40 records (order
DESC), then flips them over (order ASC) and pulls the first 20
records, then flips them over again (order DESC) to present the set
of 20 records in the desired order.&lt;/p&gt;
&lt;p&gt;This works fine if the field you are sorting on is unique for
each record, but falls down if you have a lot of records with the
same field value. SQL seems to be inconsistent in the ordering of
individual records within one unique field value.&lt;/p&gt;
&lt;p&gt;That is the order of ten records with the status &quot;open&quot; sorted
using &quot;order DESC&quot; don't seem to be mirror images of the same
records when you do the next &quot;order ASC&quot; step. That is, they may be
1,2,3,4,5,6,7,8,9,10 on the &quot;order DESC&quot; but may well be
10,8,7,3,4,5,1,2,9,6 on next &quot;order ASC&quot;&lt;/p&gt;
&lt;p&gt;This results in inconsistency when you reorder the records and
remove some at each step.&lt;/p&gt;
&lt;p&gt;What seems to fix the problem is if you add a field to the sort
that is unique for each record. id is the obvious one.&lt;/p&gt;
&lt;p&gt;So&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
SupportCase.paginate(:page =&amp;gt; params[:page],
                :per_page =&amp;gt; 20,
                :order =&amp;gt; &amp;quot;order DESC&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Results in inconsistent behaviour.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
SupportCase.paginate(:page =&amp;gt; params[:page],
                :per_page =&amp;gt; 20,
                :order =&amp;gt; &amp;quot;order DESC, id DESC&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Creates the correct results.&lt;/p&gt;
&lt;p&gt;I suggest you append &quot;, id DESC&quot; to then end of all order
statements unless id is already used in the sort.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-01-12T21:46:38+01:00</created-at>
    <creator-id type="integer">43348</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">259</number>
    <permalink>ignores-page-params-in-merb</permalink>
    <priority type="integer">111</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>agnostic merb url</tag>
    <title>Ignores page :params in merb</title>
    <updated-at type="datetime">2009-01-14T00:38:57+01:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>Jamie Wilson</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/259</url>
    <original-body>Using the agnostic branch. Trying to pass in explicit url params, which seem to be ignored when using will_paginate under merb.

I think doing something like

@@@
  def url(page)
    params = @template.request.params.except(:action, :controller).merge('page' =&gt; page)
    params.merge!(@options[:params]) if @options[:params]

    @template.url(params)
  end
@@@

fixes the problem.

There's quite probably a better way to do it though.

Thanks.</original-body>
    <latest-body>Using the agnostic branch. Trying to pass in explicit url params, which seem to be ignored when using will_paginate under merb.

I think doing something like

@@@
  def url(page)
    params = @template.request.params.except(:action, :controller).merge('page' =&gt; page)
    params.merge!(@options[:params]) if @options[:params]

    @template.url(params)
  end
@@@

fixes the problem.

There's quite probably a better way to do it though.

Thanks.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Using the agnostic branch. Trying to pass in explicit url
params, which seem to be ignored when using will_paginate under
merb.&lt;/p&gt;
&lt;p&gt;I think doing something like&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  def url(page)
    params = @template.request.params.except(:action, :controller).merge('page' =&amp;gt; page)
    params.merge!(@options[:params]) if @options[:params]

    @template.url(params)
  end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;fixes the problem.&lt;/p&gt;
&lt;p&gt;There's quite probably a better way to do it though.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2008-12-22T14:24:53+01:00</created-at>
    <creator-id type="integer">41565</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">257</number>
    <permalink>order-by-not-working-with-joined-tables</permalink>
    <priority type="integer">109</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>invalid</state>
    <tag>join sort</tag>
    <title>order by not working with joined tables</title>
    <updated-at type="datetime">2009-01-08T15:33:17+01:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>ReggieB</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/257</url>
    <original-body>I'm currently using Rails 2.1 and was using will_paginate 2.2.2. I've upgraded to mislav-will_paginate 2.3.6, but the problem persists. MS SQL 2005 database.

# The problem #
I am listing information from a CRM system. The listing pulls information from three tables. To maximise performance I'm joining the tables. This works fine, until I try to order the results. will_paginate seems to grab the order text and then escapes out the period used to identify which table the sort element belongs to. So:
@@@ORDER BY c.company_name
@@@
becomes
@@@ORDER BY c\.company_name
@@@
Which leads to a SQL error. 

As I am using MS SQL I also use square brackets in my code and these are also escaped out:
@@@ORDER BY \[c\]\.\[company_name\]
@@@

It is not the core SQL query where this occurs, but rather the encapsulating tmp1 and tmp2 entries. 

Here is my code

@@@      @opportunities = WillPaginate::Collection.create(page, per_page) do |pager|
        result = Opportunity.find(:all, 
               :select =&gt; &quot;
[o].*,
 [c].[Comp_Name] AS company_name,
 [p].[Pers_Salutation] AS person_salutation,
 [p].[Pers_FirstName] AS person_first_name,
 [p].[Pers_LastName] AS person_last_name,
 [u].[User_FirstName] AS user_first_name,
 [u].[User_LastName] AS user_last_name
&quot;,
               :conditions =&gt; conditions.join(&quot; AND &quot;),
               :joins =&gt; &quot;
AS [o]
LEFT JOIN [Company] AS [c]
  ON [o].[Oppo_PrimaryCompanyId] = [c].[Comp_CompanyId]
LEFT JOIN [Person] AS [p]
  ON [o].[Oppo_PrimaryPersonId] = [p].[Pers_PersonId]
LEFT JOIN [Users] AS [u]
  ON [o].[Oppo_AssignedUserId] = [u].[User_UserId]
&quot;,
               :order =&gt; 'c.comp_name',
               :limit =&gt; pager.per_page,
               :offset =&gt; pager.offset)
        # inject the result array into the paginated collection:
        pager.replace(result)

        unless pager.total_entries
          # the pager didn't manage to guess the total count, do it manually
          pager.total_entries = Opportunity.count(:all, :conditions =&gt; conditions.join(&quot; AND &quot;))
        end
      end
@@@

This works fine if you comment out the :order line, but fails as it is above. The SQL error this generates is here:

@@@DBI::DatabaseError: Execute
    OLE error code:80040E14 in Microsoft OLE DB Provider for SQL Server
      Incorrect syntax near '\.'.
    HRESULT error code:0x80020009
      Exception occurred.: SELECT * FROM (SELECT TOP 20 * FROM (SELECT TOP 20  
[o].*,
 [c].[Comp_Name] AS company_name,
 [p].[Pers_Salutation] AS person_salutation,
 [p].[Pers_FirstName] AS person_first_name,
 [p].[Pers_LastName] AS person_last_name,
 [u].[User_FirstName] AS user_first_name,
 [u].[User_LastName] AS user_last_name
 FROM Opportunity  
AS [o]
LEFT JOIN [Company] AS [c]
  ON [o].[Oppo_PrimaryCompanyId] = [c].[Comp_CompanyId]
LEFT JOIN [Person] AS [p]
  ON [o].[Oppo_PrimaryPersonId] = [p].[Pers_PersonId]
LEFT JOIN [Users] AS [u]
  ON [o].[Oppo_AssignedUserId] = [u].[User_UserId]
 WHERE (Oppo_CreatedDate &lt; '2008-12-01 00:00:00' AND Oppo_CreatedDate &gt; '2008-11-01 00:00:00')  ORDER BY c.comp_name) AS tmp1 ORDER BY c\.\[comp_name\] DESC) AS tmp2 ORDER BY c\.\[comp_name\]
@@@

As you can see, the problem is shown right at the end of the error message</original-body>
    <latest-body>I'm currently using Rails 2.1 and was using will_paginate 2.2.2. I've upgraded to mislav-will_paginate 2.3.6, but the problem persists. MS SQL 2005 database.

# The problem #
I am listing information from a CRM system. The listing pulls information from three tables. To maximise performance I'm joining the tables. This works fine, until I try to order the results. will_paginate seems to grab the order text and then escapes out the period used to identify which table the sort element belongs to. So:
@@@ORDER BY c.company_name
@@@
becomes
@@@ORDER BY c\.company_name
@@@
Which leads to a SQL error. 

As I am using MS SQL I also use square brackets in my code and these are also escaped out:
@@@ORDER BY \[c\]\.\[company_name\]
@@@

It is not the core SQL query where this occurs, but rather the encapsulating tmp1 and tmp2 entries. 

Here is my code

@@@      @opportunities = WillPaginate::Collection.create(page, per_page) do |pager|
        result = Opportunity.find(:all, 
               :select =&gt; &quot;
[o].*,
 [c].[Comp_Name] AS company_name,
 [p].[Pers_Salutation] AS person_salutation,
 [p].[Pers_FirstName] AS person_first_name,
 [p].[Pers_LastName] AS person_last_name,
 [u].[User_FirstName] AS user_first_name,
 [u].[User_LastName] AS user_last_name
&quot;,
               :conditions =&gt; conditions.join(&quot; AND &quot;),
               :joins =&gt; &quot;
AS [o]
LEFT JOIN [Company] AS [c]
  ON [o].[Oppo_PrimaryCompanyId] = [c].[Comp_CompanyId]
LEFT JOIN [Person] AS [p]
  ON [o].[Oppo_PrimaryPersonId] = [p].[Pers_PersonId]
LEFT JOIN [Users] AS [u]
  ON [o].[Oppo_AssignedUserId] = [u].[User_UserId]
&quot;,
               :order =&gt; 'c.comp_name',
               :limit =&gt; pager.per_page,
               :offset =&gt; pager.offset)
        # inject the result array into the paginated collection:
        pager.replace(result)

        unless pager.total_entries
          # the pager didn't manage to guess the total count, do it manually
          pager.total_entries = Opportunity.count(:all, :conditions =&gt; conditions.join(&quot; AND &quot;))
        end
      end
@@@

This works fine if you comment out the :order line, but fails as it is above. The SQL error this generates is here:

@@@DBI::DatabaseError: Execute
    OLE error code:80040E14 in Microsoft OLE DB Provider for SQL Server
      Incorrect syntax near '\.'.
    HRESULT error code:0x80020009
      Exception occurred.: SELECT * FROM (SELECT TOP 20 * FROM (SELECT TOP 20  
[o].*,
 [c].[Comp_Name] AS company_name,
 [p].[Pers_Salutation] AS person_salutation,
 [p].[Pers_FirstName] AS person_first_name,
 [p].[Pers_LastName] AS person_last_name,
 [u].[User_FirstName] AS user_first_name,
 [u].[User_LastName] AS user_last_name
 FROM Opportunity  
AS [o]
LEFT JOIN [Company] AS [c]
  ON [o].[Oppo_PrimaryCompanyId] = [c].[Comp_CompanyId]
LEFT JOIN [Person] AS [p]
  ON [o].[Oppo_PrimaryPersonId] = [p].[Pers_PersonId]
LEFT JOIN [Users] AS [u]
  ON [o].[Oppo_AssignedUserId] = [u].[User_UserId]
 WHERE (Oppo_CreatedDate &lt; '2008-12-01 00:00:00' AND Oppo_CreatedDate &gt; '2008-11-01 00:00:00')  ORDER BY c.comp_name) AS tmp1 ORDER BY c\.\[comp_name\] DESC) AS tmp2 ORDER BY c\.\[comp_name\]
@@@

As you can see, the problem is shown right at the end of the error message</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;I'm currently using Rails 2.1 and was using will_paginate 2.2.2.
I've upgraded to mislav-will_paginate 2.3.6, but the problem
persists. MS SQL 2005 database.&lt;/p&gt;
&lt;h1&gt;The problem&lt;/h1&gt;
&lt;p&gt;I am listing information from a CRM system. The listing pulls
information from three tables. To maximise performance I'm joining
the tables. This works fine, until I try to order the results.
will_paginate seems to grab the order text and then escapes out the
period used to identify which table the sort element belongs to.
So: @@@ORDER BY c.company_name&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
becomes
@@@ORDER BY c\.company_name
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which leads to a SQL error.&lt;/p&gt;
&lt;p&gt;As I am using MS SQL I also use square brackets in my code and
these are also escaped out: @@@ORDER BY [c].[company_name]&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;

It is not the core SQL query where this occurs, but rather the encapsulating tmp1 and tmp2 entries. 

Here is my code

@@@      @opportunities = WillPaginate::Collection.create(page, per_page) do |pager|
        result = Opportunity.find(:all, 
               :select =&amp;gt; &amp;quot;
[o].*,
 [c].[Comp_Name] AS company_name,
 [p].[Pers_Salutation] AS person_salutation,
 [p].[Pers_FirstName] AS person_first_name,
 [p].[Pers_LastName] AS person_last_name,
 [u].[User_FirstName] AS user_first_name,
 [u].[User_LastName] AS user_last_name
&amp;quot;,
               :conditions =&amp;gt; conditions.join(&amp;quot; AND &amp;quot;),
               :joins =&amp;gt; &amp;quot;
AS [o]
LEFT JOIN [Company] AS [c]
  ON [o].[Oppo_PrimaryCompanyId] = [c].[Comp_CompanyId]
LEFT JOIN [Person] AS [p]
  ON [o].[Oppo_PrimaryPersonId] = [p].[Pers_PersonId]
LEFT JOIN [Users] AS [u]
  ON [o].[Oppo_AssignedUserId] = [u].[User_UserId]
&amp;quot;,
               :order =&amp;gt; 'c.comp_name',
               :limit =&amp;gt; pager.per_page,
               :offset =&amp;gt; pager.offset)
        # inject the result array into the paginated collection:
        pager.replace(result)

        unless pager.total_entries
          # the pager didn't manage to guess the total count, do it manually
          pager.total_entries = Opportunity.count(:all, :conditions =&amp;gt; conditions.join(&amp;quot; AND &amp;quot;))
        end
      end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This works fine if you comment out the :order line, but fails as
it is above. The SQL error this generates is here:&lt;/p&gt;
&lt;p&gt;@@@DBI::DatabaseError: Execute&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;OLE error code:80040E14 in Microsoft OLE DB Provider for SQL Server
  Incorrect syntax near '\.'.
HRESULT error code:0x80020009
  Exception occurred.: SELECT * FROM (SELECT TOP 20 * FROM (SELECT TOP 20  
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;[o].*, [c].[Comp_Name] AS company_name, [p].[Pers_Salutation] AS
person_salutation, [p].[Pers_FirstName] AS person_first_name,
[p].[Pers_LastName] AS person_last_name, [u].[User_FirstName] AS
user_first_name, [u].[User_LastName] AS user_last_name FROM
Opportunity&lt;br&gt;
AS [o] LEFT JOIN [Company] AS [c] ON [o].[Oppo_PrimaryCompanyId] =
[c].[Comp_CompanyId] LEFT JOIN [Person] AS [p] ON
[o].[Oppo_PrimaryPersonId] = [p].[Pers_PersonId] LEFT JOIN [Users]
AS [u] ON [o].[Oppo_AssignedUserId] = [u].[User_UserId] WHERE
(Oppo_CreatedDate &amp;lt; '2008-12-01 00:00:00' AND Oppo_CreatedDate
&amp;gt; '2008-11-01 00:00:00') ORDER BY c.comp_name) AS tmp1 ORDER BY
c.[comp_name] DESC) AS tmp2 ORDER BY c.[comp_name]&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;

As you can see, the problem is shown right at the end of the error message
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2008-12-31T19:31:39+01:00</created-at>
    <creator-id type="integer">37100</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">258</number>
    <permalink>rails-22x-the-binding-argument-of-concat-is-no-longer-needed</permalink>
    <priority type="integer">110</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>duplicate</state>
    <tag>concat deprecation paginate_section</tag>
    <title>Rails 2.2.x the binding argument of concat is no longer needed</title>
    <updated-at type="datetime">2009-01-08T15:20:56+01:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>John Small</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/258</url>
    <original-body>Working in mislav-will_paginate 2.3.6 and Rails 2.2.2 when calling paginated_section you'll get an error on line 145 with a deprecation warning. This;-
&lt;pre&gt;
def paginated_section(*args, &amp;block)
      pagination = will_paginate(*args).to_s
      content = pagination + capture(&amp;block) + pagination
(line 145)      concat content, block.binding
    end
&lt;/pre&gt;

needs to be changed to;-
&lt;pre&gt;
def paginated_section(*args, &amp;block)
      pagination = will_paginate(*args).to_s
      content = pagination + capture(&amp;block) + pagination
      concat content
    end
&lt;/pre&gt; 

The extra argument to concat has been removed from Rails 2.2.x</original-body>
    <latest-body>Working in mislav-will_paginate 2.3.6 and Rails 2.2.2 when calling paginated_section you'll get an error on line 145 with a deprecation warning. This;-
&lt;pre&gt;
def paginated_section(*args, &amp;block)
      pagination = will_paginate(*args).to_s
      content = pagination + capture(&amp;block) + pagination
(line 145)      concat content, block.binding
    end
&lt;/pre&gt;

needs to be changed to;-
&lt;pre&gt;
def paginated_section(*args, &amp;block)
      pagination = will_paginate(*args).to_s
      content = pagination + capture(&amp;block) + pagination
      concat content
    end
&lt;/pre&gt; 

The extra argument to concat has been removed from Rails 2.2.x</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Working in mislav-will_paginate 2.3.6 and Rails 2.2.2 when
calling paginated_section you'll get an error on line 145 with a
deprecation warning. This;-&lt;/p&gt;
&lt;p&gt;def paginated_section(*args, &amp;amp;block)&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;  pagination = will_paginate(*args).to_s
  content = pagination + capture(&amp;amp;block) + pagination
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;(line 145) concat content, block.binding&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;end
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;needs to be changed to;-&lt;/p&gt;
&lt;p&gt;def paginated_section(*args, &amp;amp;block)&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;  pagination = will_paginate(*args).to_s
  content = pagination + capture(&amp;amp;block) + pagination
  concat content
end
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;The extra argument to concat has been removed from Rails
2.2.x&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2008-12-21T19:30:06+01:00</created-at>
    <creator-id type="integer">38488</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">256</number>
    <permalink>double-page-params-when-using-merb-1061</permalink>
    <priority type="integer">108</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>resolved</state>
    <tag nil="true"></tag>
    <title>Double page params when using merb 1.0.6.1</title>
    <updated-at type="datetime">2008-12-21T20:06:49+01:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>phatmann</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/256</url>
    <original-body>In merb 1.0.6.1, the page links are not being formed correctly after browsing to page 2, 3, etc. The links end up with double page params:

/foo?page=2&amp;page=5

The fix is to change line 8 in merb.rb

params = @template.request.params.except(:action, :controller).merge(:page =&gt; page)

TO

params = @template.request.params.except(:action, :controller).merge('page' =&gt; page)</original-body>
    <latest-body>In merb 1.0.6.1, the page links are not being formed correctly after browsing to page 2, 3, etc. The links end up with double page params:

/foo?page=2&amp;page=5

The fix is to change line 8 in merb.rb

params = @template.request.params.except(:action, :controller).merge(:page =&gt; page)

TO

params = @template.request.params.except(:action, :controller).merge('page' =&gt; page)</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;In merb 1.0.6.1, the page links are not being formed correctly
after browsing to page 2, 3, etc. The links end up with double page
params:&lt;/p&gt;
&lt;p&gt;/foo?page=2&amp;amp;page=5&lt;/p&gt;
&lt;p&gt;The fix is to change line 8 in merb.rb&lt;/p&gt;
&lt;p&gt;params = @template.request.params.except(:action,
:controller).merge(:page =&amp;gt; page)&lt;/p&gt;
&lt;p&gt;TO&lt;/p&gt;
&lt;p&gt;params = @template.request.params.except(:action,
:controller).merge('page' =&amp;gt; page)&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2008-05-16T03:50:13+02:00</created-at>
    <creator-id type="integer">6848</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">220</number>
    <permalink>has-many-through-causes-stack-level-too-deep-error</permalink>
    <priority type="integer">89</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>resolved</state>
    <tag>edge gem will_paginate</tag>
    <title>has many :through causes &quot;Stack level too deep error&quot;</title>
    <updated-at type="datetime">2008-12-17T01:14:32+01:00</updated-at>
    <user-id type="integer">18996</user-id>
    <user-name>Roger</user-name>
    <creator-name>iamjwc (at gmail)</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/220</url>
    <original-body>@@@ ruby
class Program &lt; AR::Base
  has_many :sessions, :through =&gt; :component
end

Program.find(:first).sessions # =&gt; [#&lt;Session:...&gt;, #&lt;Session:...&gt;]

Program.find(:first).sessions.first # throws SystemStackError &quot;stack level too deep&quot;
@@@

*Stack Trace*
RAILS_ROOT/vendor/plugins/will_paginate/lib/will_paginate/finder.rb:92:in `method_missing_without_paginate'
RAILS_ROOT/vendor/plugins/will_paginate/lib/will_paginate/finder.rb:93:in `method_missing'</original-body>
    <latest-body>@@@ ruby
class Program &lt; AR::Base
  has_many :sessions, :through =&gt; :component
end

Program.find(:first).sessions # =&gt; [#&lt;Session:...&gt;, #&lt;Session:...&gt;]

Program.find(:first).sessions.first # throws SystemStackError &quot;stack level too deep&quot;
@@@

*Stack Trace*
RAILS_ROOT/vendor/plugins/will_paginate/lib/will_paginate/finder.rb:92:in `method_missing_without_paginate'
RAILS_ROOT/vendor/plugins/will_paginate/lib/will_paginate/finder.rb:93:in `method_missing'</latest-body>
    <original-body-html>&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;class Program &amp;lt; AR::Base
  has_many :sessions, :through =&amp;gt; :component
end

Program.find(:first).sessions # =&amp;gt; [#&amp;lt;Session:...&amp;gt;, #&amp;lt;Session:...&amp;gt;]

Program.find(:first).sessions.first # throws SystemStackError &amp;quot;stack level too deep&amp;quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;strong&gt;Stack Trace&lt;/strong&gt;
&lt;/p&gt;&lt;p&gt;
RAILS_ROOT/vendor/plugins/will_paginate/lib/will_paginate/finder.rb:92:in `method_missing_without_paginate'
&lt;/p&gt;&lt;p&gt;
RAILS_ROOT/vendor/plugins/will_paginate/lib/will_paginate/finder.rb:93:in `method_missing'
&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2008-12-08T21:10:57+01:00</created-at>
    <creator-id type="integer">14649</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">254</number>
    <permalink>chaining-named-scopes-with-paginate-doesnt-work-with-ms-sql-server</permalink>
    <priority type="integer">106</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>activerecord-sqlserver-adapter mssql named_scope sqlserver will_paginate</tag>
    <title>Chaining named scopes with paginate doesn't work with MS SQL Server</title>
    <updated-at type="datetime">2008-12-10T16:15:37+01:00</updated-at>
    <user-id type="integer">14649</user-id>
    <user-name>Jon Canady</user-name>
    <creator-name>Jon Canady</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/254</url>
    <original-body>Using activerecord-sqlserver-adapter (1.0.0) and Rails 2.2.2.  Set up some nice named scopes to do things like filter by user_id and status, and then chained these together with the paginate scope, but I always get the first set of results regardless of the :page parameter.  However, if I code up a quick method that hacks together the :conditions parameter and call paginate manually (sans-named-scope) it seems to work fine.

Code is here: http://pastie.org/334222

For the #search method, the following SQL is being executed (for page 6):
SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 60 * FROM [TReport] WHERE (userid = '3303461' ) ORDER BY last_name) AS tmp1 ORDER BY last_name DESC) AS tmp2 ORDER BY last_name

This works.

The following SQL is being generated for the named parameters, obviously wrong:

SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 60 * FROM [T_PAExtensions2009] WHERE ((
first_name LIKE '%' OR last_name LIKE '%' OR member_id LIKE '%') AND (ncpdp = '3303461')) ORDER BY last_name) AS tmp1 ) AS tmp2

Is this an issue with activerecord-sqlserver-adapter or will_paginate?</original-body>
    <latest-body>Using activerecord-sqlserver-adapter (1.0.0) and Rails 2.2.2.  Set up some nice named scopes to do things like filter by user_id and status, and then chained these together with the paginate scope, but I always get the first set of results regardless of the :page parameter.  However, if I code up a quick method that hacks together the :conditions parameter and call paginate manually (sans-named-scope) it seems to work fine.

Code is here: http://pastie.org/334222

For the #search method, the following SQL is being executed (for page 6):
SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 60 * FROM [TReport] WHERE (userid = '3303461' ) ORDER BY last_name) AS tmp1 ORDER BY last_name DESC) AS tmp2 ORDER BY last_name

This works.

The following SQL is being generated for the named parameters, obviously wrong:

SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 60 * FROM [T_PAExtensions2009] WHERE ((
first_name LIKE '%' OR last_name LIKE '%' OR member_id LIKE '%') AND (ncpdp = '3303461')) ORDER BY last_name) AS tmp1 ) AS tmp2

Is this an issue with activerecord-sqlserver-adapter or will_paginate?</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Using activerecord-sqlserver-adapter (1.0.0) and Rails 2.2.2.
Set up some nice named scopes to do things like filter by user_id
and status, and then chained these together with the paginate
scope, but I always get the first set of results regardless of the
:page parameter. However, if I code up a quick method that hacks
together the :conditions parameter and call paginate manually
(sans-named-scope) it seems to work fine.&lt;/p&gt;
&lt;p&gt;Code is here: &lt;a href=&quot;http://pastie.org/334222&quot;&gt;http://pastie.org/334222&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For the #search method, the following SQL is being executed (for
page 6): SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 60 * FROM
[TReport] WHERE (userid = '3303461' ) ORDER BY last_name) AS tmp1
ORDER BY last_name DESC) AS tmp2 ORDER BY last_name&lt;/p&gt;
&lt;p&gt;This works.&lt;/p&gt;
&lt;p&gt;The following SQL is being generated for the named parameters,
obviously wrong:&lt;/p&gt;
&lt;p&gt;SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 60 * FROM
[T_PAExtensions2009] WHERE (( first_name LIKE '%' OR last_name LIKE
'%' OR member_id LIKE '%') AND (ncpdp = '3303461')) ORDER BY
last_name) AS tmp1 ) AS tmp2&lt;/p&gt;
&lt;p&gt;Is this an issue with activerecord-sqlserver-adapter or
will_paginate?&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2008-09-24T16:52:26+02:00</created-at>
    <creator-id type="integer">32908</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">247</number>
    <permalink>will_paginate-helper-doesnt-work-with-has_and_belongs_to_many-associations</permalink>
    <priority type="integer">99</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>invalid</state>
    <tag>will_paginate</tag>
    <title>will_paginate helper doesn't work with has_and_belongs_to_many associations.</title>
    <updated-at type="datetime">2008-12-09T16:00:40+01:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>Dipesh Batheja</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/247</url>
    <original-body>Here is how my Product model looks like:

class Product &lt; ActiveRecord::Base
  has_and_belongs_to_many :categories, :join_table =&gt; &quot;products_categories&quot;
end

In my controller, i have done this:
@products = @current_category.products.paginate :per_page =&gt; 12, :page =&gt; params[:page]

will_paginate helper doesn't show pages in the view. If manually pass page param in url, it work just fine. But will_paginate helper does not show the pages list and next and prev links.</original-body>
    <latest-body>Here is how my Product model looks like:

class Product &lt; ActiveRecord::Base
  has_and_belongs_to_many :categories, :join_table =&gt; &quot;products_categories&quot;
end

In my controller, i have done this:
@products = @current_category.products.paginate :per_page =&gt; 12, :page =&gt; params[:page]

will_paginate helper doesn't show pages in the view. If manually pass page param in url, it work just fine. But will_paginate helper does not show the pages list and next and prev links.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Here is how my Product model looks like:&lt;/p&gt;
&lt;p&gt;class Product &amp;lt; ActiveRecord::Base has_and_belongs_to_many
:categories, :join_table =&amp;gt; &quot;products_categories&quot; end&lt;/p&gt;
&lt;p&gt;In my controller, i have done this: @products =
@current_category.products.paginate :per_page =&amp;gt; 12, :page =&amp;gt;
params[:page]&lt;/p&gt;
&lt;p&gt;will_paginate helper doesn't show pages in the view. If manually
pass page param in url, it work just fine. But will_paginate helper
does not show the pages list and next and prev links.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2008-11-24T23:01:20+01:00</created-at>
    <creator-id type="integer">38770</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">253</number>
    <permalink>visible_page_numbers-is-on-where-n-is-the-number-of-pages</permalink>
    <priority type="integer">105</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>resolved</state>
    <tag nil="true"></tag>
    <title>visible_page_numbers is O(n) where n is the number of pages</title>
    <updated-at type="datetime">2008-11-25T00:42:45+01:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>Lida Tang</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/253</url>
    <original-body>visible_page_numbers will take a very long time if the number of pages you have is large, say if you are returning web search results that have millions of pages.

Here is the offending code:
      visible   = (1..total_pages).to_a &lt;&lt;&lt; O(n)
      left_gap  = (2 + outer_window)...window_from
      right_gap = (window_to + 1)...(total_pages - outer_window) &lt;&lt;&lt; Again
      visible  -= left_gap.to_a  if left_gap.last - left_gap.first &gt; 1
      visible  -= right_gap.to_a if right_gap.last - right_gap.first &gt; 1

Here is a potential fix that only depend on the size of inner+outer window:
    # these are always visible
    visible   = (window_from..window_to).to_a

    # left window
    if window_from &gt; (outer_window + 1) # fully visible
      visible = ((1..(outer_window+1)).to_a + visible)
    else # runs into visible pages
      visible = (1...window_from).to_a + visible
    end
    
    # right window
    if window_to &lt; (total_pages - outer_window) # fully visible
      visible = (visible + (total_pages - outer_window..total_pages).to_a)
    else # runs into visible pages
      visible = visible + ((window_to+1)..total_pages).to_a
    end</original-body>
    <latest-body>visible_page_numbers will take a very long time if the number of pages you have is large, say if you are returning web search results that have millions of pages.

Here is the offending code:
      visible   = (1..total_pages).to_a &lt;&lt;&lt; O(n)
      left_gap  = (2 + outer_window)...window_from
      right_gap = (window_to + 1)...(total_pages - outer_window) &lt;&lt;&lt; Again
      visible  -= left_gap.to_a  if left_gap.last - left_gap.first &gt; 1
      visible  -= right_gap.to_a if right_gap.last - right_gap.first &gt; 1

Here is a potential fix that only depend on the size of inner+outer window:
    # these are always visible
    visible   = (window_from..window_to).to_a

    # left window
    if window_from &gt; (outer_window + 1) # fully visible
      visible = ((1..(outer_window+1)).to_a + visible)
    else # runs into visible pages
      visible = (1...window_from).to_a + visible
    end
    
    # right window
    if window_to &lt; (total_pages - outer_window) # fully visible
      visible = (visible + (total_pages - outer_window..total_pages).to_a)
    else # runs into visible pages
      visible = visible + ((window_to+1)..total_pages).to_a
    end</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;visible_page_numbers will take a very long time if the number of
pages you have is large, say if you are returning web search
results that have millions of pages.&lt;/p&gt;
&lt;p&gt;Here is the offending code:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;  visible   = (1..total_pages).to_a &amp;lt;&amp;lt;&amp;lt; O(n)
  left_gap  = (2 + outer_window)...window_from
  right_gap = (window_to + 1)...(total_pages - outer_window) &amp;lt;&amp;lt;&amp;lt; Again
  visible  -= left_gap.to_a  if left_gap.last - left_gap.first &amp;gt; 1
  visible  -= right_gap.to_a if right_gap.last - right_gap.first &amp;gt; 1
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;Here is a potential fix that only depend on the size of
inner+outer window:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;# these are always visible
visible   = (window_from..window_to).to_a

# left window
if window_from &amp;gt; (outer_window + 1) # fully visible
  visible = ((1..(outer_window+1)).to_a + visible)
else # runs into visible pages
  visible = (1...window_from).to_a + visible
end

# right window
if window_to &amp;lt; (total_pages - outer_window) # fully visible
  visible = (visible + (total_pages - outer_window..total_pages).to_a)
else # runs into visible pages
  visible = visible + ((window_to+1)..total_pages).to_a
end
&lt;/code&gt;
&lt;/pre&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2008-11-07T05:05:07+01:00</created-at>
    <creator-id type="integer">36733</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">252</number>
    <permalink>fwd-git-merge-braidtrack-hit-fatal-not-a-git-repository</permalink>
    <priority type="integer">104</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>invalid</state>
    <tag nil="true"></tag>
    <title>git merge braid/track hit Fatal: Not a git repository</title>
    <updated-at type="datetime">2008-11-07T12:39:32+01:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>up1notch</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/252</url>
    <original-body>Encounter the following issue during installation of will_paginate:

When trying to run the command:



    git merge braid/track



in the dos prompt, it throw the following error:



    Fatal: Not a git repository.



I am using Windows Vista, could this be the coz? Any solution?



So I tried to install rails v2.1.2 so that I can use the &quot;ruby
script/plugin ...&quot; command to do the same job, but it pop-up an error
windows with the following error:

    The procedure entry point_apr_hash_clear@4 could not be located in
the dynamic link library libapr_tsvn.dll.

When I close the error window, another window pop-up that says:

    SVN_FILE_DESCRIPTION has stopped working...Windows searching for
solution.

This is the same error i encounter when trying to run &quot;svn.exe&quot; directly in
my DOS prompt.


Hope you can help; I am stuck on pagination for 2 days. Thanks in advance.</original-body>
    <latest-body>Encounter the following issue during installation of will_paginate:

When trying to run the command:



    git merge braid/track



in the dos prompt, it throw the following error:



    Fatal: Not a git repository.



I am using Windows Vista, could this be the coz? Any solution?



So I tried to install rails v2.1.2 so that I can use the &quot;ruby
script/plugin ...&quot; command to do the same job, but it pop-up an error
windows with the following error:

    The procedure entry point_apr_hash_clear@4 could not be located in
the dynamic link library libapr_tsvn.dll.

When I close the error window, another window pop-up that says:

    SVN_FILE_DESCRIPTION has stopped working...Windows searching for
solution.

This is the same error i encounter when trying to run &quot;svn.exe&quot; directly in
my DOS prompt.


Hope you can help; I am stuck on pagination for 2 days. Thanks in advance.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Encounter the following issue during installation of
will_paginate:&lt;/p&gt;
&lt;p&gt;When trying to run the command:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;git merge braid/track
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;in the dos prompt, it throw the following error:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;Fatal: Not a git repository.
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;I am using Windows Vista, could this be the coz? Any
solution?&lt;/p&gt;
&lt;p&gt;So I tried to install rails v2.1.2 so that I can use the &quot;ruby
script/plugin ...&quot; command to do the same job, but it pop-up an
error windows with the following error:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;The procedure entry point_apr_hash_clear@4 could not be located in
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;the dynamic link library libapr_tsvn.dll.&lt;/p&gt;
&lt;p&gt;When I close the error window, another window pop-up that
says:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;SVN_FILE_DESCRIPTION has stopped working...Windows searching for
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;solution.&lt;/p&gt;
&lt;p&gt;This is the same error i encounter when trying to run &quot;svn.exe&quot;
directly in my DOS prompt.&lt;/p&gt;
&lt;p&gt;Hope you can help; I am stuck on pagination for 2 days. Thanks
in advance.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2008-10-30T01:58:28+01:00</created-at>
    <creator-id type="integer">17482</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">251</number>
    <permalink>do-you-still-need-activesupport-as-a-gem-dependency-it-breaks-stuff</permalink>
    <priority type="integer">103</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>resolved</state>
    <tag nil="true"></tag>
    <title>Do you still need activesupport as a gem dependency?  It breaks stuff...</title>
    <updated-at type="datetime">2008-10-30T12:24:29+01:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>Chad Woolley</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/251</url>
    <original-body>I see this ticket:  

http://sod.lighthouseapp.com/projects/17958/tickets/222-edge-rails-and-mislav-will_paginate-gem-don-t-work-together

And this commit:

http://github.com/mislav/will_paginate/commit/8a64e37757a1793a6bce3e7aed2558d1e224a2df

I'm wondering if we can remove it safely now, because it causes us problems.

Here is our specific problem:

* We explicitly activate all gem versions before rails initializes (via config/preinitializer.rb).

* We sometimes activate an older version of rails than is installed on the box (e.g. app is still using rails 2.1.0 but 2.1.1 is installed as well)

* If mislav-will_paginate is activated before rails (which happens if you go in alphabetical order), the highest version of activesupport (2.1.1) will be activated.  This causes the subsequent activation of rails 2.1.1 to fail, because rails 2.1.0 tries to activate activesupport 2.1.0, which fails because you can only activate one version of a gem at a time.


Since will_paginate can only operate in the context of Rails, it doesn't seem to make sense for it to explicitly define a sub-dependency of rails as one of its dependencies.

So, unless there is a reason to keep this dependency, can we remove it?  

Thanks,
-- Chad</original-body>
    <latest-body>I see this ticket:  

http://sod.lighthouseapp.com/projects/17958/tickets/222-edge-rails-and-mislav-will_paginate-gem-don-t-work-together

And this commit:

http://github.com/mislav/will_paginate/commit/8a64e37757a1793a6bce3e7aed2558d1e224a2df

I'm wondering if we can remove it safely now, because it causes us problems.

Here is our specific problem:

* We explicitly activate all gem versions before rails initializes (via config/preinitializer.rb).

* We sometimes activate an older version of rails than is installed on the box (e.g. app is still using rails 2.1.0 but 2.1.1 is installed as well)

* If mislav-will_paginate is activated before rails (which happens if you go in alphabetical order), the highest version of activesupport (2.1.1) will be activated.  This causes the subsequent activation of rails 2.1.1 to fail, because rails 2.1.0 tries to activate activesupport 2.1.0, which fails because you can only activate one version of a gem at a time.


Since will_paginate can only operate in the context of Rails, it doesn't seem to make sense for it to explicitly define a sub-dependency of rails as one of its dependencies.

So, unless there is a reason to keep this dependency, can we remove it?  

Thanks,
-- Chad</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;I see this ticket:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://sod.lighthouseapp.com/projects/17958/tickets/222-edge-rails-and-mislav-will_paginate-gem-don-t-work-together&quot;&gt;
http://sod.lighthouseapp.com/pro...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And this commit:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://github.com/mislav/will_paginate/commit/8a64e37757a1793a6bce3e7aed2558d1e224a2df&quot;&gt;
http://github.com/mislav/will_pa...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I'm wondering if we can remove it safely now, because it causes
us problems.&lt;/p&gt;
&lt;p&gt;Here is our specific problem:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;We explicitly activate all gem versions before rails initializes
(via config/preinitializer.rb).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;We sometimes activate an older version of rails than is
installed on the box (e.g. app is still using rails 2.1.0 but 2.1.1
is installed as well)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If mislav-will_paginate is activated before rails (which happens
if you go in alphabetical order), the highest version of
activesupport (2.1.1) will be activated. This causes the subsequent
activation of rails 2.1.1 to fail, because rails 2.1.0 tries to
activate activesupport 2.1.0, which fails because you can only
activate one version of a gem at a time.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Since will_paginate can only operate in the context of Rails, it
doesn't seem to make sense for it to explicitly define a
sub-dependency of rails as one of its dependencies.&lt;/p&gt;
&lt;p&gt;So, unless there is a reason to keep this dependency, can we
remove it?&lt;/p&gt;
&lt;p&gt;Thanks, -- Chad&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">192</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">true</closed>
    <created-at type="datetime">2008-10-25T04:12:03+02:00</created-at>
    <creator-id type="integer">33263</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">250</number>
    <permalink>nomethoderror-on-first-page-multiple-associations</permalink>
    <priority type="integer">102</priority>
    <project-id type="integer">17958</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>invalid</state>
    <tag>association associations bug include nomethoderror</tag>
    <title>NoMethodError on first page (Multiple associations)</title>
    <updated-at type="datetime">2008-10-30T10:07:24+01:00</updated-at>
    <user-id type="integer">192</user-id>
    <user-name>Mislav</user-name>
    <creator-name>akshay (at mugasha)</creator-name>
    <assigned-user-name>Mislav</assigned-user-name>
    <url>http://sod.lighthouseapp.com/projects/17958/tickets/250</url>
    <original-body>Hello, I have been trying to debug this issue and then i realized that plugin was causing this. 

I am using the example of search from railscasts but I have a deep association model. 

-----ERROR---------------------------------
NoMethodError in Browses#tracks

Showing app/views//tracks.html.erb where line #18 raised:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.setTitle
Extracted source (around line #18):

15: 
16: 	&lt;% for track in @track do %&gt;
17: 		&lt;h3 style=&quot;margin-bottom: 2px&quot;&gt;
=&gt; 18: 			&lt;%= track.trackTitle%&gt; - &lt;%= track.artist.name %&gt; (&lt;%= track.dj_set.setTitle %&gt;)
19: 		&lt;/h3&gt;
20: 	&lt;% end %&gt;
21: 

---------------------------------------------

class Track
  belongs_to :dj_set 
  belongs_to :artist 
end
class dj_set
  has_many :tracks, :dependent =&gt; :destroy
end
class artist
  has_many :tracks
end

------track.html.erb------
&lt;% form_tag request.path, :method =&gt; 'get' do %&gt;
  &lt;% content_tag :label do %&gt;
    Search Tracks:
    &lt;%= text_field_tag :search, params[:search] %&gt;
  &lt;% end %&gt;
&lt;% end %&gt;

	&lt;% for track in @track do %&gt;
		&lt;h3 style=&quot;margin-bottom: 2px&quot;&gt;
			&lt;%= track.trackTitle%&gt; - &lt;%= track.artist.name %&gt; (&lt;%= track.dj_set.setTitle %&gt;)
		&lt;/h3&gt;
	&lt;% end %&gt;

------ Track.rb model -------

  def self.search(search, page)
    paginate :per_page =&gt; 20, :page =&gt; page,
             :include =&gt; [:artist, :dj_set],
             :conditions =&gt; ['trackTitle like ?', &quot;%#{search}%&quot;], :order =&gt; 'created_at'
  end

----- browse_controller.rb ------
 def tracks
    @track = Track.search(params[:search], params[:page])
end
  end
------------------------------

This WORKS fine on page &gt;2 and if any search is performed. The eror is only shown on page one. 

Correct output

Search Tracks:  --intro---
Intro - A State of Trance (374)
Intro - A State of Trance (375)
Intro - A State of Trance (373)
Intro - Trance Around the World (239)
Intro - Trance Around the World (238)

Thanks you!
Cheers,
Akshay</original-body>
    <latest-body>Hello, I have been trying to debug this issue and then i realized that plugin was causing this. 

I am using the example of search from railscasts but I have a deep association model. 

-----ERROR---------------------------------
NoMethodError in Browses#tracks

Showing app/views//tracks.html.erb where line #18 raised:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.setTitle
Extracted source (around line #18):

15: 
16: 	&lt;% for track in @track do %&gt;
17: 		&lt;h3 style=&quot;margin-bottom: 2px&quot;&gt;
=&gt; 18: 			&lt;%= track.trackTitle%&gt; - &lt;%= track.artist.name %&gt; (&lt;%= track.dj_set.setTitle %&gt;)
19: 		&lt;/h3&gt;
20: 	&lt;% end %&gt;
21: 

---------------------------------------------

class Track
  belongs_to :dj_set 
  belongs_to :artist 
end
class dj_set
  has_many :tracks, :dependent =&gt; :destroy
end
class artist
  has_many :tracks
end

------track.html.erb------
&lt;% form_tag request.path, :method =&gt; 'get' do %&gt;
  &lt;% content_tag :label do %&gt;
    Search Tracks:
    &lt;%= text_field_tag :search, params[:search] %&gt;
  &lt;% end %&gt;
&lt;% end %&gt;

	&lt;% for track in @track do %&gt;
		&lt;h3 style=&quot;margin-bottom: 2px&quot;&gt;
			&lt;%= track.trackTitle%&gt; - &lt;%= track.artist.name %&gt; (&lt;%= track.dj_set.setTitle %&gt;)
		&lt;/h3&gt;
	&lt;% end %&gt;

------ Track.rb model -------

  def self.search(search, page)
    paginate :per_page =&gt; 20, :page =&gt; page,
             :include =&gt; [:artist, :dj_set],
             :conditions =&gt; ['trackTitle like ?', &quot;%#{search}%&quot;], :order =&gt; 'created_at'
  end

----- browse_controller.rb ------
 def tracks
    @track = Track.search(params[:search], params[:page])
end
  end
------------------------------

This WORKS fine on page &gt;2 and if any search is performed. The eror is only shown on page one. 

Correct output

Search Tracks:  --intro---
Intro - A State of Trance (374)
Intro - A State of Trance (375)
Intro - A State of Trance (373)
Intro - Trance Around the World (239)
Intro - Trance Around the World (238)

Thanks you!
Cheers,
Akshay</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Hello, I have been trying to debug this issue and then i
realized that plugin was causing this.&lt;/p&gt;
&lt;p&gt;I am using the example of search from railscasts but I have a
deep association model.&lt;/p&gt;
&lt;p&gt;-----ERROR--------------------------------- NoMethodError in
Browses#tracks&lt;/p&gt;
&lt;p&gt;Showing app/views//tracks.html.erb where line &lt;a href=&quot;/projects/17958/tickets/18&quot; title=&quot;Ticket #18&quot;&gt;#18&lt;/a&gt; raised:&lt;/p&gt;
&lt;p&gt;You have a nil object when you didn't expect it! The error
occurred while evaluating nil.setTitle Extracted source (around
line &lt;a href=&quot;/projects/17958/tickets/18&quot; title=&quot;Ticket #18&quot;&gt;#18&lt;/a&gt;):&lt;/p&gt;
&lt;p&gt;15: 16: &amp;lt;% for track in @track do %&amp;gt; 17: =&amp;gt; 18: &amp;lt;%=
track.trackTitle%&amp;gt; - &amp;lt;%= track.artist.name %&amp;gt; (&amp;lt;%=
track.dj_set.setTitle %&amp;gt;) 19: 20: &amp;lt;% end %&amp;gt; 21:&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;class Track belongs_to :dj_set belongs_to :artist end class
dj_set has_many :tracks, :dependent =&amp;gt; :destroy end class artist
has_many :tracks end&lt;/p&gt;
&lt;p&gt;------track.html.erb------ &amp;lt;% form_tag request.path, :method
=&amp;gt; 'get' do %&amp;gt; &amp;lt;% content_tag :label do %&amp;gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;Search Tracks:
&amp;lt;%= text_field_tag :search, params[:search] %&amp;gt;
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;&amp;lt;% end %&amp;gt; &amp;lt;% end %&amp;gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;&amp;lt;% for track in @track do %&amp;gt;

        &amp;lt;%= track.trackTitle%&amp;gt; - &amp;lt;%= track.artist.name %&amp;gt; (&amp;lt;%= track.dj_set.setTitle %&amp;gt;)

&amp;lt;% end %&amp;gt;
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;------ Track.rb model -------&lt;/p&gt;
&lt;p&gt;def self.search(search, page)&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;paginate :per_page =&amp;gt; 20, :page =&amp;gt; page,
         :include =&amp;gt; [:artist, :dj_set],
         :conditions =&amp;gt; ['trackTitle like ?', &quot;%#{search}%&quot;], :order =&amp;gt; 'created_at'
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;end&lt;/p&gt;
&lt;p&gt;----- browse_controller.rb ------ def tracks&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;@track = Track.search(params[:search], params[:page])
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;end&lt;/p&gt;
&lt;h2&gt;end&lt;/h2&gt;
&lt;p&gt;This WORKS fine on page &amp;gt;2 and if any search is performed.
The eror is only shown on page one.&lt;/p&gt;
&lt;p&gt;Correct output&lt;/p&gt;
&lt;p&gt;Search Tracks: --intro--- Intro - A State of Trance (374) Intro
- A State of Trance (375) Intro - A State of Trance (373) Intro -
Trance Around the World (239) Intro - Trance Around the World
(238)&lt;/p&gt;
&lt;p&gt;Thanks you! Cheers, Akshay&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
</tickets>
