This commit is contained in:
ohsab 2014-12-09 20:33:23 +01:00
commit 91aa7e5644
5 changed files with 15 additions and 2 deletions

View file

@ -16,6 +16,8 @@
# last_sign_in_at :datetime
# current_sign_in_ip :string(255)
# last_sign_in_ip :string(255)
# dagschotel :reference
# dagschotel_id :integer
#
class User < ActiveRecord::Base
@ -23,11 +25,12 @@ class User < ActiveRecord::Base
:rememberable, :trackable
has_many :orders, -> { includes :products }
belongs_to :dagschotel, class_name: 'Product'
validates :nickname, presence: true, uniqueness: true
validates :name, presence: true
validates :last_name, presence: true
validates :password, length: { in: 8..128 }, confirmation: true
validates :password, length: { in: 8..128 }, confirmation: true, on: :create
def full_name
"#{name} #{last_name}"

View file

@ -0,0 +1,5 @@
class AddDagschotelToUsers < ActiveRecord::Migration
def change
add_reference :users, :dagschotel
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20141209184030) do
ActiveRecord::Schema.define(version: 20141209192545) do
create_table "order_products", force: true do |t|
t.integer "order_id"
@ -54,6 +54,7 @@ ActiveRecord::Schema.define(version: 20141209184030) do
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.integer "dagschotel_id"
t.boolean "admin"
end

View file

@ -16,6 +16,8 @@
# last_sign_in_at :datetime
# current_sign_in_ip :string(255)
# last_sign_in_ip :string(255)
# dagschotel :reference
# dagschotel_id :integer
#
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

View file

@ -16,6 +16,8 @@
# last_sign_in_at :datetime
# current_sign_in_ip :string(255)
# last_sign_in_ip :string(255)
# dagschotel :reference
# dagschotel_id :integer
#
require 'test_helper'