diff --git a/app/controllers/donations_controller.rb b/app/controllers/donations_controller.rb index ba5cdb36..e818065b 100644 --- a/app/controllers/donations_controller.rb +++ b/app/controllers/donations_controller.rb @@ -28,7 +28,7 @@ class DonationsController < ApplicationController @features.each(&:save!) end rescue ActiveRecord::RecordInvalid - flash[:error] = "Couldn't save donation details. Do those outfits exist?" + flash[:alert] = "Couldn't save donation details. Do those outfits exist?" redirect_to @donation else flash[:success] = 'Donation details saved! ' + diff --git a/app/models/donation_feature.rb b/app/models/donation_feature.rb index bd0c7bb0..0d650aa5 100644 --- a/app/models/donation_feature.rb +++ b/app/models/donation_feature.rb @@ -2,7 +2,7 @@ class DonationFeature < ActiveRecord::Base belongs_to :donation belongs_to :outfit - validates :outfit, presence: true, if: :outfit_id? + validates :outfit, presence: true, if: :outfit_id_present? delegate :donor_name, to: :donation @@ -13,4 +13,8 @@ class DonationFeature < ActiveRecord::Base def outfit_url=(outfit_url) self.outfit_id = outfit_url.split('/').last rescue nil end + + def outfit_id_present? + outfit_id.present? + end end