Sha256: 1b3d353c5145f3d217f3b1a4e23602a3483c1c441e8181be6647297423d53a57

Contents?: true

Size: 883 Bytes

Versions: 9

Compression:

Stored size: 883 Bytes

Contents

require 'type_cartographer'

module People
  class V1::User < ActiveRecord::Base
    self.table_name = 'people_users'
    
    before_save { self.email = email.downcase }
    before_save { self.username = username.downcase }

  <% if options.arcadex? %>
  	has_many :tokens, :as => :imageable, :class_name => "::Arcadex::Token"
  <% end %>
  	has_secure_password

  	after_create :setup_user

    validates :username, presence: true, :uniqueness => { :case_sensitive => false }
    #validates_format_of :username, :with => /\A[A-Za-z0-9\d]+\Z/i
    validates :email, presence: true, :uniqueness => { :case_sensitive => false }
    #Might need a regex for emails, or just rather confirm them

  <% if options.arcadex? %>
    def setup_user
    	create_token
    end

    def create_token
      self.tokens.create!
    end
  <% else %>
    def setup_user
    end
  <% end %>
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
json_voorhees-1.0.0 lib/generators/json_voorhees/app_make_user/templates/user/user_model.rb
json_voorhees-0.5.5 lib/generators/json_voorhees/app_make_user/templates/user/user_model.rb
json_voorhees-0.5.4 lib/generators/json_voorhees/app_make_user/templates/user/user_model.rb
json_voorhees-0.5.3 lib/generators/json_voorhees/app_make_user/templates/user/user_model.rb
json_voorhees-0.5.2 lib/generators/json_voorhees/app_make_user/templates/user/user_model.rb
json_voorhees-0.5.1 lib/generators/json_voorhees/app_make_user/templates/user/user_model.rb
json_voorhees-0.5.0 lib/generators/json_voorhees/app_make_user/templates/user/user_model.rb
json_voorhees-0.4.9 lib/generators/json_voorhees/app_make_user/templates/user/user_model.rb
json_voorhees-0.4.8 lib/generators/json_voorhees/app_make_user/templates/user/user_model.rb