hey,
i have users who are in groups, and i have a search form, where i can search on
group, user lastname, and user firstname.
All this is also with pagination.
these are my models
class User < ActiveRecord::Base
has_and_belongs_to_many :groups
end
class Group < ActiveRecord::Base
has_and_belongs_to_many :users
end
in my controller i do this
THIS works (but in need pagination)
@users2 = User.find_by_sql("select users.* from groups, users, groups_users
where groups.id = " + @group_id.to_s + " and groups_users.group_id =
groups.id
and groups_users.user_id = users.id and users.last_name like ''%" +
@last_name.to_s + "%'' order by users.last_name ASC,
users.first_name ASC")
i get an error on this (can anyone help me???)
@user_pages, @users = paginate :user, :conditions => [''users.firm_id
= ? and
users.first_name like ? and users.last_name like ?'', @firm_id,
"%#{@first_name}%", "%#{@last_name}%"] ,:include =>
[:groups], :order_by =>
"users.last_name ASC, users.first_name ASC", :per_page => 10
private method `scan'' called for #<Array:0x31da378>
RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace
active_record/associations.rb:964:in`include_eager_conditions?''
:952:in`construct_finder_sql_for_association_limiting''
active_record/associations.rb:946:in`select_limited_ids_list''
active_record/associations.rb:939:in`add_limited_ids_condition!''
:929:in`construct_finder_sql_with_included_associations''
active_record/associations.rb:917:in`select_all_rows''
active_record/associations.rb:830:in`find_with_associations''
active_record/base.rb:411:in`find''
action_controller/pagination.rb:174:in`find_collection_for_pagination''
action_controller/pagination.rb:192:in`paginator_and_collection_for''
action_controller/pagination.rb:124:in`paginate''
active_record/associations.rb:964:in`include_eager_conditions?''
952:in`construct_finder_sql_for_association_limiting''
active_record/associations.rb:946:in`select_limited_ids_list''
active_record/associations.rb:939:in`add_limited_ids_condition!''
:929:in`construct_finder_sql_with_included_associations''
active_record/associations.rb:917:in`select_all_rows''
active_record/associations.rb:830:in`find_with_associations''
active_record/base.rb:411:in`find''
action_controller/pagination.rb:174:in`find_collection_for_pagination''
action_controller/pagination.rb:192:in`paginator_and_collection_for''
action_controller/pagination.rb:124:in`paginate''
action_controller/base.rb:841:in`send''
action_controller/base.rb:841:in`perform_action_without_filters''
action_controller/filters.rb:332:in`perform_action_without_benchmark''
action_controller/benchmarking.rb:69:in`perform_action_without_rescue''
action_controller/benchmarking.rb:69:in`measure''
action_controller/benchmarking.rb:69:in`perform_action_without_rescue''
action_controller/rescue.rb:82:in`perform_action''
action_controller/base.rb:365:in`send''