I am trying to create a table to handle both the location and the category in which a particular campaign was installed with the following model associations:
class Campaign < ActiveRecord::Base has_many :campaign_category_metro_bids, dependent: :destroy has_many :metros, through: :campaign_category_metro_bids has_many :categories, through: :campaign_category_metro_bids end class Metro < ActiveRecord::Base has_many :campaign_category_metro_bids has_many :campaigns, through: :campaign_category_metro_bids has_many :categories, through: :campaign_category_metro_bids end class Category < ActiveRecord::Base has_many :campaign_category_metro_bids has_many :campaigns, through: :campaign_category_metro_bids has_many :metros, through: :campaign_category_metro_bids end class CampaignCategoryMetroBid < ActiveRecord::Base belongs_to :campaign belongs_to :category belongs_to :metro end
When trying to create a campaign to select two different cities and categories, the result is NULL for the identifier of one of the parameters as:

Campaign Creation Code:
def new if signed_in?
UPDATED The view for creating the campaign uses two separate collection_select objects for the category and Metro as:
<%= f.collection_select :category_ids, Category.all, :id, :display_category, {}, {multiple: true} %>
and
<%= f.collection_select :metro_ids, Metro.all, :id, :full_name, {}, {multiple: true} %>
campaigns_params:
def campaign_params params.require(:campaign).permit(:name, :campaign_category_metro_bid_id, :metro_ids => [], :category_ids => []) end
Is there a better way to allow the creation of a relation of 3 tables as I try? or a way to bind Category and Metro models when choosing so that the resulting table looks like this when creating a campaign:
