title: Rails - How to create multiple "matches" in one action between a user and opportunities?
body: <p>I'm looking for the easiest and the most clever way to create interest_id(match) in one-click.</p>
  
  <p>Here is my MVC : </p>
  
  <p>user.rb</p>
  
  <pre><code>class User &lt; ApplicationRecord
    has_many :interests, through: :opportunities
  end
  </code></pre>
  
  <p>interest.rb</p>
  
  <pre><code>class Interest &lt; ApplicationRecord
    belongs_to :opportunity
    belongs_to :user
  end
  </code></pre>
  
  <p>opportunity.rb</p>
  
  <pre><code>class Opportunity &lt; ApplicationRecord
    has_many :interests
  end
  </code></pre>
  
  <p>InterestsController.rb</p>
  
  <pre><code>def create
    @user = current_user
    @opportunities = Opportunity.all
    @interest = Interest.new(interest_params)
    if @interest.save!
      redirect_to user_interests_path, notice: 'it works'
    else
      render :new, notice:"it doesn't work"
    end
  end
  
  def interest_params
    params.permit(
      :user_id,
      :opportunity_id)
  end
  </code></pre>
  
  <p>user/show</p>
  
  <pre><code>&lt;%= link_to "Match", user_interests_path(@user), class:"btn btn-primary", :method =&gt; :post %&gt;
  </code></pre>
  
  <p>For now, I can't pass opportunities (nil). Could you please advise me about the easiest way to create interests? (New on RoR for 6 months). 
  Many thanks for your help. </p>