Skip to content

Commit

Permalink
Add poject models and associations
Browse files Browse the repository at this point in the history
  • Loading branch information
fezzopro committed Sep 12, 2023
1 parent c8edd64 commit a25083d
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/entity.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Entity < ApplicationRecord
belongs_to :user
end
3 changes: 3 additions & 0 deletions app/models/group.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Group < ApplicationRecord
belongs_to :user
end
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class User < ApplicationRecord
has_many :entities
has_many :groups
end
8 changes: 8 additions & 0 deletions db/migrate/20230912134007_create_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class CreateUsers < ActiveRecord::Migration[7.0]
def change
create_table :users do |t|
t.string :name
t.timestamps
end
end
end
11 changes: 11 additions & 0 deletions db/migrate/20230912134307_create_groups.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateGroups < ActiveRecord::Migration[7.0]
def change
create_table :groups do |t|
t.string :name
t.string :icon
t.references :user, null: false, foreign_key: true

t.timestamps
end
end
end
11 changes: 11 additions & 0 deletions db/migrate/20230912134451_create_entities.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateEntities < ActiveRecord::Migration[7.0]
def change
create_table :entities do |t|
t.string :name
t.float :amount
t.references :user, null: false, foreign_key: true

t.timestamps
end
end
end
5 changes: 5 additions & 0 deletions spec/models/entity_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

RSpec.describe Entity, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
5 changes: 5 additions & 0 deletions spec/models/group_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

RSpec.describe Group, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
5 changes: 5 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

RSpec.describe User, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit a25083d

Please sign in to comment.