Are you not creating a many to many with this table setup. In which case, if you use the rails methods it will reduce the amount of thinking you need to do to access the various relationships:
Unless I have misunderstood you:
class Group < ActiveRecord::Base has_many :user_groups has_many :contacts, :through=>:user_groups end
class Contact < ActiveRecord::Base has_many :groups, :through=>:user_groups has_many :user_groups end
class UserGroup < ActiveRecord::Base belongs_to :group belongs_to :contact end
So that you can do @group=Group.find(params[:group_id]) @contacts=@group.contacts.paginate(:page=>params[:page])
(if you don't need @group, you could combine this into one line) Although, that is 2 fetches from the database, I reckon that is easier to see
Tonypm