Ben modellerin aşağıdaki kümesi vardır:Raylar Has_many: özel ile içinden foreign_key
ActiveRecord::StatementInvalid: PGError: ERROR: operator does not exist: character varying = integer
LINE 1: ...".palette_color_id WHERE (("color_matches".hex = 66)) OR...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT "palette_colors".* FROM "palette_colors" INNER JOIN "color_matches" ON "palette_colors".id = "color_matches".palette_color_id WHERE (("color_matches".hex = 66)) ORDER BY name ASC
Bu bana ActiveRecord üretir sorgu kullanarak olduğunu gösterir:
class Cardstock < ActiveRecord::Base
has_many :color_matches, :primary_key => :hex, :foreign_key => :hex
has_many :palette_colors, :through => :color_matches
end
class ColorMatch < ActiveRecord::Base
belongs_to :palette_color
has_many :cardstocks, :foreign_key => :hex, :primary_key => :hex
end
class PaletteColor < ActiveRecord::Base
has_many :color_matches
has_many :cardstocks, :through => :color_matches
end
Cardstock.last.palette_colors
çağrılması aşağıdaki hata verir kart stoğunun altı (bbbbaf
) kullanıldığında kart stoğu numarası (66
). Bir yerlerde, cardstocks
ve color_matches
arasında katılmak için hex
sütununu kullanmak için ActiveRecord'a belirtmem gerekiyor. ActiveRecord bunu destekliyor mu?
Bu, Rails 2.3.x sürümüdür. –