use grouping:
Book.where(:user_id => @user.id).grouped('title_id')
Problem
is that if you group, you cannot have different book identifiers, they are all grouped into one line. You can use GROUP_CONCAT to work around:
Book...select('books.*, GROUP_CONCAT(id) as ids')
this way you will have the book ids attribute for each group
source share