class Subscription < ActiveRecord::Base
validates :feed_id, presence: true, uniqueness: true
现在我验证了用户不能按照上述代码两次订阅相同的提要,我想在通知中指定他们已经订阅了提要。如果验证失败,我该如何指定条件,发送除通用“订阅不成功”以外的通知
class SubscriptionsController < ApplicationController
def new
#do things
if @subscription.save
redirect_to reader_url, notice: "You are now subscribed to: "+feed.title
else
redirect_to reader_url, notice: "Subscribe was unsuccessful!"
end
end