generate models

This commit is contained in:
Ilion Beyst 2015-09-08 11:30:11 +02:00
parent aeb6f90e98
commit f96ddba717
13 changed files with 119 additions and 0 deletions

2
app/models/client.rb Normal file
View file

@ -0,0 +1,2 @@
class Client < ActiveRecord::Base
end

View file

@ -0,0 +1,4 @@
class Transaction < ActiveRecord::Base
belongs_to :debtor
belongs_to :creditor
end

6
app/models/user.rb Normal file
View file

@ -0,0 +1,6 @@
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end

View file

@ -1,4 +1,5 @@
Rails.application.routes.draw do Rails.application.routes.draw do
devise_for :users
# The priority is based upon order of creation: first created -> highest priority. # The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes". # See how all your routes lay out with "rake routes".

View file

@ -0,0 +1,45 @@
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.string :name
t.integer :balance
t.boolean :penning
t.timestamps null: false
end
add_index :users, :email, unique: true
add_index :users, :reset_password_token, unique: true
# add_index :users, :confirmation_token, unique: true
# add_index :users, :unlock_token, unique: true
end
end

View file

@ -0,0 +1,13 @@
class CreateTransactions < ActiveRecord::Migration
def change
create_table :transactions do |t|
t.references :debtor, index: true, foreign_key: true
t.references :creditor, index: true, foreign_key: true
t.integer :amount
t.string :origin
t.string :message
t.timestamps null: false
end
end
end

View file

@ -0,0 +1,10 @@
class CreateClients < ActiveRecord::Migration
def change
create_table :clients do |t|
t.string :name
t.string :key
t.timestamps null: false
end
end
end

View file

@ -0,0 +1,7 @@
FactoryGirl.define do
factory :client do
name "MyString"
key "MyString"
end
end

View file

@ -0,0 +1,10 @@
FactoryGirl.define do
factory :transaction do
debtor nil
creditor nil
amount 1
origin "MyString"
message "MyString"
end
end

6
spec/factories/users.rb Normal file
View file

@ -0,0 +1,6 @@
FactoryGirl.define do
factory :user do
end
end

View file

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Client, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Transaction, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

5
spec/models/user_spec.rb Normal file
View file

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe User, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end