Skip to content

Commit 06ff56c

Browse files
authored
Merge pull request #5 from tuanle03/clr-72-create-model-follow
[CLR-72] Create model Follow
2 parents 6515a5f + b1ca31c commit 06ff56c

File tree

1,839 files changed

+193
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,839 files changed

+193
-3
lines changed
Binary file not shown.

.gitignore

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
*.rbc
2+
capybara-*.html
3+
.rspec
4+
/db/*.sqlite3
5+
/db/*.sqlite3-journal
6+
/db/*.sqlite3-[0-9]*
7+
/public/system
8+
/coverage/
9+
/spec/tmp
10+
*.orig
11+
rerun.txt
12+
pickle-email-*.html
13+
14+
# Ignore all logfiles and tempfiles.
15+
/log/*
16+
/tmp/*
17+
!/log/.keep
18+
!/tmp/.keep
19+
20+
# TODO Comment out this rule if you are OK with secrets being uploaded to the repo
21+
config/initializers/secret_token.rb
22+
config/master.key
23+
24+
# Only include if you have production secrets in this file, which is no longer a Rails default
25+
# config/secrets.yml
26+
27+
# dotenv, dotenv-rails
28+
# TODO Comment out these rules if environment variables can be committed
29+
.env
30+
.env*.local
31+
32+
## Environment normalization:
33+
/.bundle
34+
/vendor/bundle
35+
36+
# these should all be checked in to normalize the environment:
37+
# Gemfile.lock, .ruby-version, .ruby-gemset
38+
39+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
40+
.rvmrc
41+
42+
# if using bower-rails ignore default bower_components path bower.json files
43+
/vendor/assets/bower_components
44+
*.bowerrc
45+
bower.json
46+
47+
# Ignore pow environment settings
48+
.powenv
49+
50+
# Ignore Byebug command history file.
51+
.byebug_history
52+
53+
# Ignore node_modules
54+
node_modules/
55+
56+
# Ignore precompiled javascript packs
57+
/public/packs
58+
/public/packs-test
59+
/public/assets
60+
61+
# Ignore yarn files
62+
/yarn-error.log
63+
yarn-debug.log*
64+
.yarn-integrity
65+
66+
# Ignore uploaded files in development
67+
/storage/*
68+
!/storage/.keep
69+
/public/uploads

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
4242
# Reduces boot times through caching; required in config/boot.rb
4343
gem "bootsnap", require: false
4444

45+
gem "devise"
46+
4547
# Use Sass to process CSS
4648
# gem "sassc-rails"
4749

Gemfile.lock

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ GEM
6868
tzinfo (~> 2.0)
6969
addressable (2.8.6)
7070
public_suffix (>= 2.0.2, < 6.0)
71+
bcrypt (3.1.20)
7172
bindex (0.8.1)
7273
bootsnap (1.17.0)
7374
msgpack (~> 1.2)
@@ -87,6 +88,12 @@ GEM
8788
debug (1.9.0)
8889
irb (~> 1.10)
8990
reline (>= 0.3.8)
91+
devise (4.9.3)
92+
bcrypt (~> 3.0)
93+
orm_adapter (~> 0.1)
94+
railties (>= 4.1.0)
95+
responders
96+
warden (~> 1.2.3)
9097
erubi (1.12.0)
9198
globalid (1.2.1)
9299
activesupport (>= 6.1)
@@ -130,6 +137,7 @@ GEM
130137
nokogiri (1.14.2)
131138
mini_portile2 (~> 2.8.0)
132139
racc (~> 1.4)
140+
orm_adapter (0.5.0)
133141
psych (5.1.1.1)
134142
stringio
135143
public_suffix (5.0.4)
@@ -172,6 +180,9 @@ GEM
172180
regexp_parser (2.8.3)
173181
reline (0.4.1)
174182
io-console (~> 0.5)
183+
responders (3.1.1)
184+
actionpack (>= 5.2)
185+
railties (>= 5.2)
175186
rexml (3.2.6)
176187
rubyzip (2.3.2)
177188
selenium-webdriver (4.10.0)
@@ -198,6 +209,8 @@ GEM
198209
railties (>= 6.0.0)
199210
tzinfo (2.0.6)
200211
concurrent-ruby (~> 1.0)
212+
warden (1.2.9)
213+
rack (>= 2.0.9)
201214
web-console (4.2.0)
202215
actionview (>= 6.0.0)
203216
activemodel (>= 6.0.0)
@@ -222,6 +235,7 @@ DEPENDENCIES
222235
bootsnap
223236
capybara
224237
debug
238+
devise
225239
importmap-rails
226240
jbuilder
227241
puma (~> 5.0)

app/.DS_Store

0 Bytes
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class FollowsController < ApplicationController
2+
end

app/helpers/follows_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module FollowsHelper
2+
end

app/models/comment.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
11
class Comment < ApplicationRecord
2+
belongs_to :user
3+
belongs_to :linked_object, polymorphic: true
4+
5+
validates :body, presence: true
6+
validates :user_id, presence: true
7+
validates :linked_object_id, presence: true
8+
validates :linked_object_type, presence: true
9+
10+
def self.create_comment(user, linked_object, body)
11+
comment = Comment.new
12+
comment.user = user
13+
comment.linked_object = linked_object
14+
comment.body = body
15+
comment.save
16+
comment
17+
end
18+
19+
def self.delete_comment(user, comment)
20+
if user == comment.user
21+
comment.destroy
22+
return true
23+
end
24+
false
25+
end
226
end

app/models/discussion.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
class Discussion < ApplicationRecord
2+
belongs_to :user
3+
4+
has_many :comments, as: :linked_object
5+
has_many :votes, as: :linked_object
26
end

app/models/feedback.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
class Feedback < ApplicationRecord
2+
belongs_to :user
3+
4+
has_many :comments, as: :linked_object
5+
has_many :votes, as: :linked_object
26
end

0 commit comments

Comments
 (0)