私は2つのモデル、入札と入札を行っています。RailsでPG :: ForeignKeyViolationエラーが発生した場合、Flash通知メッセージを表示するには
class Bidding < ActiveRecord::Base
has_many :bidding_items, dependent: :restrict_with_error
accepts_nested_attributes_for :bidding_items, reject_if: :all_blank, allow_destroy: true
end
class BiddingItem < ActiveRecord::Base
belongs_to :bidding
end
次の依存関係を入札モデルに追加すると、エラーは発生しませんが、依然としてユーザーにメッセージを表示したいと思います。私が代わりにこのエラービューを取得したり(私は前に述べた依存関係を使用して)全くエラーが発生していないのユーザーにフラッシュ通知メッセージを表示することができる方法
has_many :bidding_items, dependent: :restrict_with_error
?毎回このようなエラーがそのコントローラにoccurrs「上げる」ために、