Sha256: f6d30414e525089811c202de006d6b6840e42855f8371de4112bff929b414cf5

Contents?: true

Size: 964 Bytes

Versions: 39

Compression:

Stored size: 964 Bytes

Contents

# {User}s are the administrators of a blog. 
# Since there is no interface to manage users, they have to be modified via
# Rails console. 
# 
# Examples:
#   rails c
#   # Create a new user:
#   User.create(email: 'mail@example.com', password: 'ultrasekret')
#   # Find a specific user and modify:
#   u = User.where(email: 'mail@example.com')
#   u.email = 'new@example.com'
#   u.password = 'newsecret'
#   u.save

module Lines

  class User < ActiveRecord::Base
    # use bcrypt-ruby to encrypt passwords
    has_secure_password validations: false
    validates :password, length: { minimum: 6 }, allow_blank: false
    validates :password, presence: true, on: :create

    # Validations
    validates :password, length: { minimum: 6 }, if: :validate_password?
    validates :email, uniqueness: true, presence: true

    
    private 
      # Returns +true+ if a password is submitted
      def validate_password?
        password.present?
      end

  end

end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
lines-engine-0.5 app/models/lines/user.rb
lines-engine-0.4.6.4 app/models/lines/user.rb
lines-engine-0.4.6.3 app/models/lines/user.rb
lines-engine-0.4.6.1 app/models/lines/user.rb
lines-engine-0.4.6 app/models/lines/user.rb
lines-engine-0.4.5 app/models/lines/user.rb
lines-engine-0.4.4 app/models/lines/user.rb
lines-engine-0.4.2 app/models/lines/user.rb
lines-engine-0.4.1 app/models/lines/user.rb
lines-engine-0.4 app/models/lines/user.rb
lines-engine-0.3.3.2 app/models/lines/user.rb
lines-engine-0.3.3.1 app/models/lines/user.rb
lines-engine-0.3.3 app/models/lines/user.rb
lines-engine-0.3.2 app/models/lines/user.rb
lines-engine-0.3.1 app/models/lines/user.rb
lines-engine-0.3 app/models/lines/user.rb
lines-engine-0.2 app/models/lines/user.rb
lines-engine-0.1.25 app/models/lines/user.rb
lines-engine-0.1.24 app/models/lines/user.rb
lines-engine-0.1.23 app/models/lines/user.rb