Add dagschotel to users
This commit is contained in:
parent
465b9198ab
commit
9fe6bf7530
5 changed files with 15 additions and 2 deletions
|
@ -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}"
|
||||
|
|
5
db/migrate/20141209192545_add_dagschotel_to_users.rb
Normal file
5
db/migrate/20141209192545_add_dagschotel_to_users.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddDagschotelToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_reference :users, :dagschotel
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20141209172818) 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: 20141209172818) do
|
|||
t.datetime "last_sign_in_at"
|
||||
t.string "current_sign_in_ip"
|
||||
t.string "last_sign_in_ip"
|
||||
t.integer "dagschotel_id"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
2
test/fixtures/users.yml
vendored
2
test/fixtures/users.yml
vendored
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue