Open hirolibe opened 1 month ago
引数に「Userクラスのインスタンス」が入る場合と、「user_id」が入る場合で場合分けする
class User < ApplicationRecord
・・・
def follow!(user)
if user.is_a?(User)
user_id = user.id
else
user_id = user
end
following_relationships.create!(following_id: user_id)
end
end
引数として「params[:account_id]」を渡す場合、idの値が渡されるのか?
◯app/models/user.rb
◯app/controllers/follows_controller.rb