Skip to content

class_name #157

@justqyx

Description

@justqyx

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 #8, but nobody has given the solution!
Please help me, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions