質問編集履歴
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -130,6 +130,18 @@
|
|
130
130
|
irb(main):002:0>
|
131
131
|
```
|
132
132
|
|
133
|
+
**RAILS_ENV=production rails db:migrate の結果**
|
134
|
+
一度git pullして最新にし、RAILS_ENV=production rails db:migrateを実行したログです。
|
135
|
+
きっと実行したときに下にログが出るはずなのですが、何も出ずに入力に進んでしまいます。
|
136
|
+
```
|
137
|
+
[ec2-user@ip-(プライベートIP) *]$ git pull origin main
|
138
|
+
From https://github.com/(名前)/*
|
139
|
+
* branch main -> FETCH_HEAD
|
140
|
+
Already up to date.
|
141
|
+
[ec2-user@ip-(プライベートIP) *]$ RAILS_ENV=production rails db:migrate
|
142
|
+
[ec2-user@ip-(プライベートIP) *]$
|
143
|
+
```
|
133
144
|
|
134
145
|
|
135
146
|
|
147
|
+
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -123,6 +123,12 @@
|
|
123
123
|
end
|
124
124
|
|
125
125
|
```
|
126
|
+
**RAILS_ENV=production rails c の結果**
|
127
|
+
```
|
128
|
+
irb(main):001:0> User.column_names.sort
|
129
|
+
=> ["created_at", "email", "encrypted_password", "id", "nickname", "remember_created_at", "reset_password_sent_at", "reset_password_token", "updated_at"]
|
130
|
+
irb(main):002:0>
|
131
|
+
```
|
126
132
|
|
127
133
|
|
128
134
|
|
1
指定箇所追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -35,4 +35,95 @@
|
|
35
35
|
・EC2の再起動
|
36
36
|
・git pull→マイグレーションの動作
|
37
37
|
|
38
|
+
### 追記
|
38
39
|
|
40
|
+
**db/schema.rbのusers**
|
41
|
+
```
|
42
|
+
create_table "users", force: :cascade do |t|
|
43
|
+
t.datetime "created_at", precision: 6, null: false
|
44
|
+
t.datetime "updated_at", precision: 6, null: false
|
45
|
+
t.string "email", default: "", null: false
|
46
|
+
t.string "encrypted_password", default: "", null: false
|
47
|
+
t.string "reset_password_token"
|
48
|
+
t.datetime "reset_password_sent_at"
|
49
|
+
t.datetime "remember_created_at"
|
50
|
+
t.string "nickname", null: false
|
51
|
+
t.string "testimonials", default: "", null: false
|
52
|
+
t.index ["email"], name: "index_users_on_email", unique: true
|
53
|
+
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
54
|
+
end
|
55
|
+
```
|
56
|
+
**app/models/users.rb**
|
57
|
+
```
|
58
|
+
class User < ApplicationRecord
|
59
|
+
# Include default devise modules. Others available are:
|
60
|
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
61
|
+
devise :database_authenticatable, :registerable,
|
62
|
+
:recoverable, :rememberable, :validatable
|
63
|
+
|
64
|
+
has_one_attached :image
|
65
|
+
# has_many :likes, dependent: :destroy
|
66
|
+
has_many :niced_tweets, through: :nices, source: :tweet
|
67
|
+
def already_niced?(tweet)
|
68
|
+
self.nices.exists?(tweet_id: tweet.id)
|
69
|
+
end
|
70
|
+
|
71
|
+
has_many :inquiry
|
72
|
+
|
73
|
+
has_many :revues
|
74
|
+
def already_revued?(shop)
|
75
|
+
self.revues.exists?(shop_id: shop.id)
|
76
|
+
end
|
77
|
+
|
78
|
+
# フォローした人を作る
|
79
|
+
has_many :follows, class_name: "Follow", foreign_key: "user_follower_id", dependent: :destroy
|
80
|
+
# フォローした人の一覧
|
81
|
+
has_many :user_followings, through: :follows, source: :user_followed
|
82
|
+
|
83
|
+
#フォローされた人の中間テーブル
|
84
|
+
has_many :reverse_of_follows, class_name: "Follow", foreign_key: "user_followed_id", dependent: :destroy
|
85
|
+
#フォローされた人に一覧
|
86
|
+
has_many :user_followers, through: :reverse_of_follows, source: :user_follower
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
# フォローしたときの処理
|
92
|
+
def user_follow(user)
|
93
|
+
#byebug
|
94
|
+
follows.find_or_create_by(user_followed_id: user.id)
|
95
|
+
end
|
96
|
+
|
97
|
+
# フォローを外すときの処理
|
98
|
+
def user_unfollow(user)
|
99
|
+
follows.find_by(user_followed_id: user.id)&.destroy
|
100
|
+
end
|
101
|
+
|
102
|
+
# フォローしているか判定
|
103
|
+
def user_following?(user)
|
104
|
+
user_followings.include?(user)
|
105
|
+
end
|
106
|
+
|
107
|
+
def get_image(width, height)
|
108
|
+
unless image.attached?
|
109
|
+
file_path = Rails.root.join('app/assets/images/no_image.jpg')
|
110
|
+
image.attach(io: File.open(file_path), filename: 'default-image.jpg', content_type: 'image/jpeg')
|
111
|
+
end
|
112
|
+
image.variant(resize: "#{width}x#{height}").processed
|
113
|
+
end
|
114
|
+
|
115
|
+
# 退会時の削除内容
|
116
|
+
has_many :nices, :dependent => :destroy
|
117
|
+
has_many :tweets , :dependent => :destroy
|
118
|
+
has_many :inquiries , :dependent => :destroy
|
119
|
+
has_many :revues , :dependent => :destroy
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
```
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|