Mein Zustand Modell wie folgt aussieht:Postgresql spezifische Datenbankfehler: "Active :: StatementInvalid: PGError: ERROR: Operator existiert nicht"
class State < ActiveRecord::Base
belongs_to :country
named_scope :order_by_name, :order => :name
validates_presence_of [:country, :name]
def <=>(other)
name <=> other.name
end
end
Mein Land Modell wie folgt aussieht:
class Country < ActiveRecord::Base
has_many :states
named_scope :order_by_name, :order => :name
def <=>(other)
name <=> other.name
end
end
Dies funktioniert in einer SQLite-Umgebung:
>> Country.find_by_iso("US").states
=> [#<State id: 1, name: "Alaska", abbr: "AK", # .....
Aber in einer postgresql Umgebung, bekomme ich diese:
>> Country.find_by_iso("US").states
ActiveRecord::StatementInvalid: PGError: ERROR: operator does not exist: character varying = integer
LINE 1: SELECT * FROM "states" WHERE ("states".country_id = 214)
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT * FROM "states" WHERE ("states".country_id = 214)
Irgendwelche Gedanken?
Gefragt und beantwortet. – tpdi