title: How to add data into join table from form in Rails?
body: <p>I have three models in my rails application. When I create a new notification how do I rewrite the notifications_controller.rb and the form in notifications/new.html.erb so that the entry gets saved to the notifications_users table? Thanks</p>
  
  <p>schema.rb</p>
  
  <pre><code>create_table "notifications", force: :cascade do |t|
   t.string "title"
   t.string "first_name"
   t.string "last_name"
   t.datetime "date"
   t.text "content"
   t.datetime "created_at", null: false
   t.datetime "updated_at", null: false
  
   end
  
  create_table "notifications_users", id: false, force: :cascade do |t|
   t.bigint "user_id", null: false
   t.bigint "notification_id", null: false
   end
  
  create_table "users", force: :cascade do |t|
   t.string "first_name"
   t.string "last_name"
   t.string "user_type"
   t.string "username"
   t.string "password"
   t.datetime "created_at", null: false
   t.datetime "updated_at", null: false
   t.string "password_digest"
   t.index ["username"], name: "index_users_on_username", unique: true
  
  end
  </code></pre>
  
  <p>new.html.erb</p>
  
  <pre><code>&lt;h1&gt;New Message&lt;/h1&gt;
  
   &lt;div class="row"&gt;
   &lt;div class="col-md-6 col-md-offset-3"&gt;
  
   &lt;%= form_for(@notification, url: notifications_new_path) do |f| %&gt;
  
    &lt;%= f.label :title %&gt;
    &lt;%= f.text_field :title, class: 'form-control' %&gt;
  
  
    &lt;%= f.label :first_name %&gt;
    &lt;%= f.text_field :first_name, class: 'form-control' %&gt;
  
    &lt;%= f.label :date %&gt;
    &lt;%= f.datetime_field :date %&gt;
  
    &lt;%= f.label :content %&gt;
    &lt;%= f.text_area :content, class: 'form-control' %&gt;
  
    &lt;%= f.submit "Create my message", class: "btn btn-primary" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>
  
  
  <p>notifications_controller.rb</p>
  
  <pre><code>def create
    @notification = Notification.new(notification_params)    
  
    if @notification.save
      flash[:success] = "Notification created!"
      redirect_to @notification 
   else
     render 'new'
   end
  end
  </code></pre>