Forum: Ruby on Rails Pagination with conditions + include

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
HOGANBP (Guest)
on 2005-11-15 00:02
(Received via mailing list)
Windows, current rails 0.14.3



Hmmm... It appears that this doesn't work...

@task_pages, @tasks = paginate :task, :include=>[:project, :tasktimes],
:conditions=>["tasks.project_id = ?", params['pid']], :per_page => 10


But this does

    @task_pages, @tasks = paginate :task, :conditions=>["project_id =
?", @params['pid']], :per_page => 10

And so does this

    @task_pages, @tasks = paginate :task, :include=>[:project,
:tasktimes], :per_page => 10


And by "doesn't work" I mean


NoMethodError in Task#list

private method `scan' called for ["project_id = ?", 1]:Array

RAILS_ROOT: ./script/../config/..

Application Trace <http://localhost:3000/project/show/1#>  | Framework
Trace <http://localhost:3000/project/show/1#>  | Full Trace
<http://localhost:3000/project/show/1#>
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/ass
ociations.rb:912:in `include_eager_conditions?'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/ass
ociations.rb:900:in `construct_finder_sql_for_association_limiting'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/ass
ociations.rb:894:in `select_limited_ids_list'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/ass
ociations.rb:887:in `add_limited_ids_condition!'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/ass
ociations.rb:877:in `construct_finder_sql_with_included_associations'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/ass
ociations.rb:865:in `select_all_rows'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/ass
ociations.rb:778:in `find_with_associations'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/bas
e.rb:396:in `find'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/p
agination.rb:173:in `find_collection_for_pagination'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/p
agination.rb:191:in `paginator_and_collection_for'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.10.2/lib/action_controller/p
agination.rb:123:in `paginate'
#{RAILS_ROOT}/app/controllers/task_controller.rb:19:in `list'
#{RAILS_ROOT}/app/views/project/show.rhtml:140


So... is this something I should report or is this already on the list
of things to fix? Or am I just being dense?


Brian H.
Web D.
Learning & Technology Services
Schofield 3-B
University of Wisconsin-Eau Claire
715 836 3585
removed_email_address@domain.invalid
This topic is locked and can not be replied to.