I tried to call an existing class using FileSearchable.new(current_user, params[:keyword]).call but I am getting the error, undefined method 'where' for nil:NilClass on my_folders = my_folders.where("name ILIKE ?", filter) unless filter.blank?
The class is below
class FileSearchable attr_accessor :user, :my_files, :my_folders, :shared_folders, :shared_files, :filter def initialize(user, filter) @user = user @my_folders = user.folders @my_files = user.user_documents @shared_folders = user.shared_folders @shared_files = user.user_documents @filter = filter end def apply_search_params my_folders = my_folders.where("name ILIKE ?", filter) unless filter.blank? end end I am not sure why the my_folders variable is not being set.