polivalente 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/polivalente/follow.rb +28 -0
- data/db/migrate/20220221013006_create_follows.rb +12 -0
- data/lib/polivalente/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 146bf51ffb686507752d9274f8a5d262a9e054cf950a8b8421c380d39e5cc3b6
|
4
|
+
data.tar.gz: b6e0bcf9c5c8e547161ad7055152845b6fc1a968d010c5d3ee634b212f47ef85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bfd9568faede360eb560d5bfd8de1dab24dced76ef527186b068e16bf7708678a70829dab51bd6aa2bda7352fa156b604bf8ea85b044c305532d88e40457b57
|
7
|
+
data.tar.gz: c18b1b3423636bd0db2faa11c48aba56af50d2be08dcc9e8dd8d108b85504df3c782be8e74e2450edf54b19250aadb9318faf83e80ae9355f6d8dc2840ad06cf
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Polivalente
|
2
|
+
class Follow < ApplicationRecord
|
3
|
+
include Sortable
|
4
|
+
|
5
|
+
belongs_to :follower, class_name: Polivalente.config.user_class
|
6
|
+
belongs_to :followee, class_name: Polivalente.config.user_class
|
7
|
+
|
8
|
+
validates_presence_of :follower
|
9
|
+
validates_presence_of :followee
|
10
|
+
validate :not_following_yourself!
|
11
|
+
|
12
|
+
# broadcasts_to -> (follow) { "follows" }
|
13
|
+
|
14
|
+
def follower_name
|
15
|
+
follower.name
|
16
|
+
end
|
17
|
+
|
18
|
+
def followee_name
|
19
|
+
followee.name
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def not_following_yourself!
|
25
|
+
errors.add "a user can only follow someone else" if follower == followee
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateFollows < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :follows do |t|
|
4
|
+
t.references :follower, null: false, foreign_key: { to_table: :users, on_delete: :cascade }
|
5
|
+
t.references :followee, null: false, foreign_key: { to_table: :users, on_delete: :cascade }
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
|
10
|
+
add_index :follows, [:follower_id, :followee_id], unique: true, name: "index_unique_follow_relationship"
|
11
|
+
end
|
12
|
+
end
|
data/lib/polivalente/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polivalente
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leo Neto
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- app/models/polivalente/application_record.rb
|
156
156
|
- app/models/polivalente/archive.rb
|
157
157
|
- app/models/polivalente/comment.rb
|
158
|
+
- app/models/polivalente/follow.rb
|
158
159
|
- app/models/polivalente/reaction.rb
|
159
160
|
- app/models/polivalente/tag.rb
|
160
161
|
- app/models/polivalente/tagging.rb
|
@@ -176,6 +177,7 @@ files:
|
|
176
177
|
- db/migrate/20220125144339_create_reactions.rb
|
177
178
|
- db/migrate/20220125144342_create_trash.rb
|
178
179
|
- db/migrate/20220130033524_create_archives.rb
|
180
|
+
- db/migrate/20220221013006_create_follows.rb
|
179
181
|
- lib/generators/polivalente/controllers/controllers_generator.rb
|
180
182
|
- lib/generators/polivalente/install/install_generator.rb
|
181
183
|
- lib/generators/polivalente/templates/README
|