0
subsriber.rbvalidates_confirmation_of:消息未出現
class Subscriber < ActiveRecord::Base
validates_confirmation_of :email, :message => "Your emails don't match!"
end
我有這個在我的Rails應用程序。當我沒有匹配的電子郵件 創建一個新的記錄下面是我創建行動:
def create
@subscriber = Subscriber.new(params[:subscriber])
if @subscriber.save
redirect_to root_path, :notice => "You've been subscribed!"
else
render 'new'
end
end
如何讓我的錯誤消息中的視圖文件顯示?我沒有看到文檔中的任何內容,說我需要添加一些內容到我的視圖中,但消息沒有顯示出來。
你應該看看簡單形式或Formtastic,因爲它們都直接將此功能構建到表單中。 – 2012-04-22 17:32:31
的意思是檢查這兩個,但我認爲學習如何使用這些將花費比我昨晚要做的更長。只是收集電子郵件地址。 – mehulkar 2012-04-22 19:45:10