Give Each User A Friends List With Rails Associations - Ruby On Rails Friend List App #8
ฝัง
- เผยแพร่เมื่อ 2 ม.ค. 2025
- In this video I'll show you how to create friend lists for each logged in user by using Rails Associations.
Rails Associations allow us to associate different tables of our database together. It allows us to say, hey...this friend belongs to this user; and this user has many friends.
Database Table Associations with Rails are really easy to do, and you'll learn how to do them in this video!
▶️ Watch Entire Ruby on Rails Playlist ✅ Subscribe To My TH-cam Channel:
bit.ly/3hvlr7P bit.ly/2IGzvOR
▶️ See More At: ✅ Join My Facebook Group:
Codemy.com bit.ly/2GFmOBz
▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt!
Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN
▶️ Get The Code
bit.ly/3iLOq97
what if someone inspects the page changes the id value, and submits, does it add a friend to another user?
You should assign the current user id inside the controller or model instead of as a hidden input. Thanks.
yeah, you' re right, in the method create :
"
@friend = Friend.new(friend_params)
@friend.user_id = current_user.id "
Cleanest and more secure
would you be able to show how a sorting feature would work with ruby on rails, with say sort by first name in alphabetical order?
Fantastic tutorial!
Thanks!
Very Nice
Thanks
Thank you
You're welcome!