У меня есть форма, которая отправляет уведомление, когда клиент заполняет форму.Я знаю, хотел бы иметь возможность сохранить эту информацию в моей таблице базы данных, но у меня возникла проблема.Он не сохраняет копию в базе данных вообще, если я не очищаю свою модель.вот как выглядят контроллер и модель.
class ContactController < ApplicationController
def index
@contact = Contact.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @contact }
end
end
def create
@contact = Contact.new(params[:contact])
if verify_recaptcha(request.remote_ip, params)[:status] == 'false'
render 'index', :layout => '/layouts/application.html.erb'
elsif
respond_to do |format|
if @contact.save
format.html { redirect_to("/contact", :notice => 'Your Message was successfully sent.') }
else
format.html { render :action => "index" }
format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }
end
end
end
end
end
модель
class Contact < ActiveRecord::Base
include ActiveModel::Validations
validates_presence_of :email, :phone, :phone_type, :address, :fullName, :content, :userBrowser, :userOS
attr_accessor :id, :email, :phone, :phone_type, :address, :fullName, :content, :userBrowser, :userOS
def initialize(attributes = {})
attributes.each do |key, value|
self.send("#{key}=", value)
end
@attributes = attributes
end
def read_attribute_for_validation(key)
@attributes[key]
end
def to_key
end
def save
if self.valid?
Notifier.contact_notification(self).deliver
return true
end
return false
end
end
вся помощь приветствуется!