2012-09-23 02:39:12 +00:00
|
|
|
require 'open-uri'
|
|
|
|
|
|
|
|
class User < ActiveRecord::Base
|
|
|
|
|
|
|
|
has_many :items
|
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
|
|
|
|
|
|
|
acts_as_authentic do |configuration|
|
|
|
|
configuration.session_class = Session
|
2012-09-30 03:45:14 +00:00
|
|
|
configuration.require_password_confirmation = false
|
|
|
|
|
|
|
|
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? }
|
2012-09-23 02:39:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
validates :password, :presence => true,
|
2012-10-29 17:52:29 +00:00
|
|
|
:length => {
|
|
|
|
:maximum => 20,
|
|
|
|
:too_long => "is too long (maximum is %{count} characters)" },
|
2012-09-23 02:39:12 +00:00
|
|
|
:on => :create
|
2012-10-29 17:52:29 +00:00
|
|
|
validates :password, :allow_blank => true,
|
|
|
|
:length => {
|
|
|
|
:maximum => 20,
|
|
|
|
:too_long => "is too long (maximum is %{count} characters)"},
|
2012-09-23 02:39:12 +00:00
|
|
|
:on => :update
|
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
|
2012-09-23 02:39:12 +00:00
|
|
|
|
|
|
|
end
|