2012-09-23 02:39:12 +00:00
|
|
|
require 'open-uri'
|
|
|
|
|
|
|
|
class User < ActiveRecord::Base
|
|
|
|
|
2013-01-01 22:45:35 +00:00
|
|
|
has_many :topics
|
2012-10-18 00:51:54 +00:00
|
|
|
has_many :synapses
|
2012-10-26 10:04:52 +00:00
|
|
|
has_many :maps
|
|
|
|
has_many :mappings
|
2012-09-23 02:39:12 +00:00
|
|
|
|
2013-07-10 18:02:38 +00:00
|
|
|
devise :database_authenticatable, :recoverable, :rememberable, :trackable # :registerable
|
|
|
|
|
|
|
|
#acts_as_authentic do |configuration|
|
|
|
|
# configuration.session_class = Session
|
|
|
|
#configuration.require_password_confirmation = false
|
2012-09-30 03:45:14 +00:00
|
|
|
|
2013-07-10 18:02:38 +00:00
|
|
|
# configuration.merge_validates_format_of_email_field_options unless: Proc.new { |user| user.email.blank? and user.authed? }
|
|
|
|
# configuration.merge_validates_length_of_email_field_options unless: Proc.new { |user| user.email.blank? and user.authed? }
|
|
|
|
#end
|
2012-09-23 02:39:12 +00:00
|
|
|
|
2013-01-26 01:49:40 +00:00
|
|
|
serialize :settings, UserPreference
|
2012-10-29 17:52:29 +00:00
|
|
|
|
|
|
|
validates :joinedwithcode, :presence => true, :inclusion => { :in => User.all.map(&:code), :message => "%{value} is not a valid code" }, :on => :create
|
2013-01-26 01:49:40 +00:00
|
|
|
|
|
|
|
def settings
|
|
|
|
# make sure we always return a UserPreference instance
|
|
|
|
if read_attribute(:settings).nil?
|
|
|
|
write_attribute :settings, UserPreference.new
|
|
|
|
read_attribute :settings
|
|
|
|
else
|
|
|
|
read_attribute :settings
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def settings=(val)
|
|
|
|
write_attribute :settings, val
|
|
|
|
end
|
2012-09-23 02:39:12 +00:00
|
|
|
end
|