I have an application with rich client (react+redux) and rails 5 backend API.
In first approximation, we have 3 models
issue.rb
has_many :issue_participants, dependent: :destroy
has_many :participants, through: :issue_participants, class_name: 'User'
issue_participant.rb
belongs_to :issue
belongs_to :participant, class_name: 'User', foreign_key: 'user_id'
and user.rb
has_many :issue_participants, dependent: :destroy
has_many :issues, through: :issue_participants
I want to add participants to issue at frontend side. This will be happen in react component, where redux-form with user's collection will be render (only users, nothing else of current issue).
I choose from two options:
Update an issue with selected users via
IssuesController#update
action by passingissues_participant_ids: []
to params. Please note that we have no this action right now, because it wasn't needed before today.Create
IssueParticipant
records viaIssueParticipantsController#create
action.
Both options works. Which one should be given preference in the context of predictable consequences?