Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

scope name with column names fail #117

Open
sbounmy opened this Issue · 1 comment

1 participant

@sbounmy

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

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.