Pagination with conditions + include


#1

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:inconstruct_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:inadd_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:inselect_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:infind’
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:inpaginator_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:inlist’
#{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