有一個聯繫頁面,它提供輸入姓名,電話,電子郵件和信息,然後發送給管理員的電子郵件。沒有理由將消息存儲在數據庫中。來自控制器的導軌驗證
問題。如何:
使用Rails的驗證控制器中,不使用模式可言,或模型
使用驗證,但沒有任何DB關係
UPD:
型號: 型號:控制器:
def sendmessage
cpm = ContactPageMessage.new()
if cpm.valid?
@settings = Setting.first
if [email protected]
redirect_to contacts_path, :alert => "Fail"
end
if ContactPageMessage.received(params).deliver
redirect_to contacts_path, :notice => "Success"
else
redirect_to contacts_path, :alert => "Fail"
end
else
redirect_to contacts_path, :alert => "Fail"
end
end
end
我想你已經有一個同名的'ContactPageMessage'類。這是問題。 –
是否要將名稱,電話和電子郵件保存在數據庫中,只有消息需要驗證並且未保存在數據庫中? – user2801
@sumi,我不想被任何東西保存到數據庫中。剛剛驗證。 – Roman