Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7718181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:06:09+00:00 2026-06-01T03:06:09+00:00

Hello I am trying to build a multi select to populate a many-to-many join

  • 0

Hello I am trying to build a multi select to populate a many-to-many join table. I am able to crate the new newform but am getting “AssociationTypeMismatch” when I try to save my record.
The solutions that I am finding on the web are not solving my problem.
Hoping someone can resolve what I should be doing to get rid of “AssociationTypeMismatch”

class Presenter < ActiveRecord::Base
   belongs_to :seminar
   belongs_to :person
end

class Seminar < ActiveRecord::Base
  attr_accessible  :description, :title,
  has_many :presenters, :foreign_key => "person_id" 
  has_many :lecturer, :through => :presenters, :source => :person
  accepts_nested_attributes_for :lecturer, :presenters
end

class Person < ActiveRecord::Base
  attr_accessible :first_name, :last_name
  has_many :presentors
  has_many :lecturingAt, :through => :presentors

  def fullName
      first_name + " " + last_name
  end
end

seminars_controller.rb

def new
  @seminar = Seminar.new
  @current_presenters = Person.find(:all)
  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render :xml => @seminar }
  end
end
....
def create
  @seminar = Seminar.new(params[:seminar])
  respond_to do |format|
    if @seminar.save
      format.html { redirect_to(@seminar, :notice => 'Seminar was successfully created.') }
      format.xml  { render :xml => @seminar, :status => :created, :location => @seminar } 
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @seminar.errors, :status => :unprocessable_entity }
    end
  end
end

Seminars/_form.html.erb. has which populates my collection select with the names and persion ids of
possible lecurers.

....
<div class="field">
<%= f.label :presenter_id %><br />
<%= collection_select(:seminar,:lecturer,@current_presenters, :id, :fullName,{}, {:multiple=>true} ) %>
....

On submitting the params passed into my controller

Parameters: {...., "seminar"=>{ "lecturer"=>["1", "2"], "title"=>"1234567890", "description"=>"ASDFGHJKL:"}, "commit"=>"Create Seminar"}

Getting error:

ActiveRecord::AssociationTypeMismatch (Instructor(#86075540) expected, got String(#73495120)):.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:06:11+00:00Added an answer on June 1, 2026 at 3:06 am
    @seminar = Seminar.new
    

    Try this

    @seminar.lecturer_ids = params[:seminar].delete(:lecturer)
    @seminar.update_attributes(params[:seminar])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build Hello, Android with the Android SDK, but Android won't say
Hello i'm trying to build a table cell using div tag and while doing
I'm trying to build Hello World in x64 assembly on my Leopard MacBook Pro.
I'm trying to build a server that will handle many concurrent connections to iPhone
Hello dearest community, I am trying to build a simple AutoUpdate application using VB.NET.
I am trying to build my hello-world program in LINQ. While executing the following
I'm trying to build hello world on Objective-C on Linux (Ubuntu). main.c #import <Foundation/Foundation.h>
I'm trying to deploy my simple Qt project like a hello world. I build
Background: Hello I am trying to build a windows workflow like state engine. I
I'm trying to build a hello world using GTK, which includes the line: #include

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.