Answer the question
In order to leave comments, you need to log in
How to add members to a project?
Hello everyone) There is a table of participants (participant.rb) and teams (team.rb) I want to make it so that when creating a team, a list of participants appears and each of them can be added to the team. Here are the links of the models.
class < ActiveRecord::Base
has_many :participant_teams
has_many :teams, through: :participant_teams
end
class Team < ActiveRecord::Base
has_many :participant_teams
has_many :participants, through: :participant_teams
end
class ParticipantTeam < ActiveRecord::Base
belongs_to :team
belongs_to : participant
end
Let's say I created a team and went to the team page. On the team page there is a button to add members, when clicked, a list of members appears in a modal window. And under each participant there is a button to add him to the team.
class TeamsController < ApplicationController
def participant_collection
@participants = Participant.all
respond_to do |format| // returns all members in js format on the teams/1
page format.js {}
end
end
end
How do I write a method that will add members to a team? Share your knowledge, experience. Maybe there is another way to do it. Thank you all in advance.)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question