Reputation: 395
I have a method:
def can_book_appointment?
and i want to use it in a scope for the activeadmin gem
scope :cannot_book_appointment, lambda { |self| , {:condition => !self.can_book_appointment?}
I did try
scope :place_cannot_book, lambda { PlaceDetail.all.reject{|n| !n.can_book_appointment?} }
but i get a error in activeadmin:
undefined method 'reorder' for #< Array:0x121bf5e8>
I know this doesn't work, but it helps to get an idea of my intention. How can I use this method on each records of the model?
Upvotes: 1
Views: 63
Reputation: 239311
You can't do that. Scopes are applied at the database-level, your can_book_appointment?
method exists at the model level. They can't interact the way you're trying to make them interact.
You need to define a second scope that applies the same check that can_book_appointment?
performs, but at the database level.
Upvotes: 3