I am following this tutorial http://railscasts.com/episodes/29-group-by-month
and have built a system to allow a user to assign a contact to a specific label. However I need pagination such that it only returns the first 3 labels, second 3 labels, etc.
How do I go about doing this in ActiveRecord
def index
@connections = @current_user.user_contacts.where('label_id > 0').order("updated_at")
@connections_label = @connections.group_by { |t| t.label_id }
end
Contact Table
ID | Name | Label_ID
01 | Mike | 1
Label Table
ID | Name
1 | PSU
UPDATED
You could try
takeWhat are you using for pagination? If you wanted to print this out in erb, it would be something like this.
This would give you the first 3 labels:
In your controller you should be able to something like @VVN suggested: