Reputation: 2265
I am trying to use will_pagination in my project, seems very easy, but I have this consult to show a list of idea...
@ideas= current_company.ideas.find_all_by_status_and_creator_id('editable', current_user.id) +
current_company.ideas.find_all_by_status('valid') +
current_company.ideas.find_all_by_status_and_creator_id('purchable', !current_user.id)
so I modified it like this, to use the paginate
current_company.ideas.where(:status => ['editable', 'valid'], :creator_id=> current_user.id).paginate ....
but how I include the last condition?
If I include status "purchable" in the array, How to do to take the other user distint of current_user?
any idea
Upvotes: 0
Views: 29
Reputation: 15089
Hmm, i believe you have to create a where
string.
current_company.ideas.where(
"
(status IN ('editable', 'valid') AND creator_id = ?)
AND
(status = 'purchable' AND creator_id <> ?)
",
current_user.id, !current_user.id).paginate...
Beware that maybe you will have to put the table name before the attributes like ideas.status
.
Upvotes: 1