RUBY ON RAILS ADVANCED
Links
// ASSOCIATIONS <
Connect tables
Models concerns > tablas de friends y users (o los nombres que les hayamos dado)
class Friend < Application Record
belongs_to :user
end
class User < Application Record
#...other code
has_many :friends
end
Create new field in friends table
check db > schema.rb // you can see the columns of the tables
#Add a column
rails g migration add_user_id_to_friends user_id:integer:index #add user id to the table friends
rails db:migrate
2:39
<=% form.number_field :user_id, id: :friend_user_id class:"form-control", value: current_user.id, type: :hidden %>
// <
// <
// <
// <
// <
// <