Sha256: 5e8835b00fed37af5f87263907f1044942ef96a9c2627be907ea049b5d48bdae

Contents?: true

Size: 686 Bytes

Versions: 1

Compression:

Stored size: 686 Bytes

Contents

require 'type_cartographer'

module People
  class V1::User < ActiveRecord::Base
    self.table_name = 'people_users'

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

  	after_create :setup_user

    validates :username, presence: true
    #validates_format_of :username, :with => /\A[A-Za-z0-9\d]+\Z/i
    validates :email, presence: true
    #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

1 entries across 1 versions & 1 rubygems

Version Path
json_voorhees-0.3.9 lib/generators/json_voorhees/app_make_user/templates/user/user_model.rb