Я пытаюсь дать пользователю возможность изменить статус входящих запросов друга от «непринятый» на «принято»Обновление атрибутов модели в Ruby,
пользователя Модель
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
has_many :places
has_many :sent_friendships, class_name: "Friendship" , foreign_key: :sender_id
has_many :received_friendships, class_name: "Friendship", foreign_key: :receiver_id
Дружба Модель
class Friendship < ActiveRecord::Base
belongs_to :sender, class_name: "User"
belongs_to :receiver, class_name: "User"
end
Пользователь Show View
<h1>Incoming Friend Requests</h1>
<% current_user.received_friendships.each do |friendship| %>
<%= friendship.sender.name %>
<%= link_to "Accept", user_accept_path(current_user), class: 'btn btn-success', method: :post %>
<% end %>
Дружеские Контроллер
class FriendshipsController < ApplicationController
def accept
@user = User.find(params[:user_id])
end
end
Где, где я спотыкаясь, потому что я не уверен, как лучше плюс в ИО отправителя и идентификатора получателя для обновления соответствующей строки на столе модели дружбы.
Любая помощь приветствуется.
Огромное спасибо, что я смог его решить! –