search_methods - scope vs class method
kryachkov opened this issue · 1 comments
kryachkov commented
I have a class:
class User < AR::Base
search_methods :patients_without_alert_recipients
def self.patients_without_alert_recipients
joins('LEFT OUTER JOIN alert_recipients ON alert_recipients.owner_id = users.id').where("users.user_type = 'patient' AND users.role IS NULL AND users.id != ? AND alert_recipients.id IS NULL", DEFAULT_USER_ID)
end
end
When I try to search User model by this method i get wrong number of arguments (1 for 0) error. When this method is defined as scope all works fine
meta_search version is 1.1.3
kryachkov commented
So as MetaSearch passes the form value to this method (In case of check_box it equals 1) class method should be defined as
def self.patients_without_alert_recipients(*args)
I found that methods defined as scopes do not raise an exception when passed arguments
I suppose it should be mentioned in Readme