2
我有三個型號的Rails:顯示相關模型驗證
class RateCard < ActiveRecord::Base
validate :name, :presence => true, :uniqueness => true
has_many :rate_card_countries, :dependent => :destroy
has_many :rate_card_details, :dependent => :destroy
has_many :countries, :through => :rate_card_countries
end
class RateCardCountry < ActiveRecord::Base
validates :country_id, :presence => true, :uniqueness => true
validates :rate_card_id, :presence => true
belongs_to :rate_card
belongs_to :country
end
class Country < Geography
has_one :rate_card
has_one :rate_card_country
end
在rate_cards_controller我想創建/更新rate_cards這樣一個國家應該有一個rate_card .. 對於我已經在RateCardCountry添加獨特的驗證模型。 而NOw我想在創建/更新rate_cards時在rate_card_controller中顯示錯誤.. 需要幫助嗎?