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

class_name #157

Open justqyx opened 12 years ago

justqyx commented 12 years ago

because of some reason,I have to do like this:

class Fabric < ActiveRecord::Base has_many :fabric_material_records end

class FabricMaterialRecord::Base belongs_to :fabric belongs_to :material, :class_name => "Fabric" end

however,as the result:

FabricMaterialRecord.material_number_like("PP"); will give on the console:(It's error) FabricMaterialRecord Load (0.1ms) SELECT fabric_material_records.* FROM fabric_material_records INNER JOIN fabrics ON fabrics.id IS NULL WHERE (fabrics.number LIKE '%PP%')

FabricMaterialRecord.fabric_number_like("PP") will give(It's correct!) FabricMaterialRecord Load (0.1ms) SELECT fabric_material_records.* FROM fabric_material_records INNER JOIN fabrics ON fabrics.id = fabric_material_records.fabric_id WHERE (fabrics.number LIKE '%PP%')

I'll have see one issue at https://github.com/binarylogic/searchlogic/issues/8, but nobody has given the solution! Please help me, thanks!