binarylogic / searchlogic

Searchlogic provides object based searching, common named scopes, and other useful tools.
http://rdoc.info/projects/binarylogic/searchlogic
MIT License
1.4k stars 133 forks source link

scope name with column names fail #117

Open sbounmy opened 13 years ago

sbounmy commented 13 years ago

Hi,

I have an issue with searchlogic (since 2.4.25). When trying to loop in an array of method_names with association.send(method_name), sometimes it return searchlogic result instead of the method result !

For example : def Client def pdf_methods [ :city, :zip_code, :full_name, :full_address1_and_2, :full_address1, :address2, :phone_number, :mobile_number, :fax_number, :email, :lastname, :firstname, :mr_age, :ms_age, :family_status_human, :mr_pro_status_human, :ms_pro_status_human, :childrens, :is_tax_credit, :tax_credit, :tax_credit_date, :house, :owner, :construction_under_2_years, :roof_chimney, :roof_sit_dog, :roof_other, :roof_velux, :roof_slope, :debt_ratio, :pending_credit, :north, :south, :east, :west, :near_protected_site, :is_renewable_energies_survey, :renewable_energies_survey, :roof_sheathing_human, :roof_area, :comment_telepro, :couple_present, :zip_code_city ] end

def Appointment
  belongs_to :client

  def to_pdf
      client.pdf_methods.map { |method_name| client.send(method_name) }
  end
end

Appointment.last.to_pdf #returns an array with method results and searchlogic scope result... => when :owner method_name, i have an array of clients

sbounmy commented 13 years ago

i noticed it calls searchlogic scope column name when we call the attribute from an association using send and if the column is a boolean : Appointment.last.client.send(:owner) # => SELECT * FROM clients WHERE (clients.owner = 1)