I am using mysql + webrick
Saving an instance of a model class inserts null values or zeros
instead of the actual values
Code below has some lines commented since I noticed a thread
where one individual encountered a similar situation but no
confirmed solution was identified.
Thanks in advance.
def save_refer_friends
begin
@email = params[:email1]
@id = session[:user].id
@refer_friends = ReferFriends.new(@email, Time.now, @id)
@refer_friends = ReferFriends.new()
@refer_friends.email = @email
@refer_friends.ref_user_id = session[:user].id
@refer_friends.event_time = Time.now
@refer_friends.save
redirect_to '/'
rescue Exception => e
logger.error e
redirect_to '/'
end
end
class ReferFriends < ActiveRecord::Base
#validates_presence_of :email, :event_time, :ref_user_id
#attr_writer :ref_user_id, :event_time, :email
#attr_reader :email, :ref_user_id, :event_time
def email
@email
end
def event_time
@event_time
end
def ref_user_id
@ref_user_id
end
def email=(email)
@email = email
end
def event_time=(event_time)
@event_time = event_time
end
def ref_user_id=(ref_user_id)
@ref_user_id = ref_user_id
end
end