hi list, using models with a legacy database: class User < ActiveRecord::Base set_table_name ''ilt_insured_login_tbl'' set_primary_key ''ilt_id'' set_column_prefix ''ilt_'' has_many :policies, :foreign_key => ''ilp_ilt_id'' end class Policy < ActiveRecord::Base set_table_name ''ilp_insured_login_policy_tbl'' set_primary_key ''ilp_ilt_id'' set_column_prefix ''ilp_'' belongs_to :user, :foreign_key => ''ilt_id'' end .. i want to paginate a search query looking at both models, e.g. @user_pages, @users = paginate :users, { :per_page => 15, :order => ''lower(ilt_email)'', :conditions => ["lower(ilt_email) like lower(?) or lower(ilp_policy_num) like lower(?)", q, q], :include => :policies } the API docs say that you cannot define conditions on an association if using eager loading, and accordingly i get errors when trying the above code so, A: how would i perform such a query and B: how can i paginate the results? thanks, jeff --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
jemminger
2006-Sep-25 19:01 UTC
Re: how to do LIKE search across associations and paginate?
well, a little more googling and found a solution: http://thebogles.com/blog/2006/06/paginate_by_sql-for-rails-a-more-general-approach/ works great for my situation. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---