# Join table not getting populated habtm

**URL:** <https://www.ruby-forum.com/t/join-table-not-getting-populated-habtm/71987>\
**Category:** Rails\
**Created:** [October 13, 2006, 5:20am UTC](https://www.ruby-forum.com/t/join-table-not-getting-populated-habtm/71987 "2006-10-13T05:20:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![railrocks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c4cdca/32.png) [@railrocks](https://www.ruby-forum.com/u/railrocks)\
**Post date:** [October 13, 2006, 5:20am UTC](https://www.ruby-forum.com/t/join-table-not-getting-populated-habtm/71987/1 "2006-10-13T05:20:04Z")

</div>

I have two tables am\_bas and am\_applications on oracle database.

I created them thru following migrate scripts

class CreateAmBas \< ActiveRecord::Migration  
def self.up  
create\_table :am\_bas do |t|  
t.column :business\_area, :string  
t.column :created\_on, :datetime  
t.column :created\_at, :datetime  
t.column :updated\_on, :datetime  
t.column :updated\_at, :datetime  
t.column :lock\_version, :integer  
end  
create\_table(“am\_applications\_am\_bas”, :id=\>false) do |t|  
t.column “am\_application\_id”, :integer  
t.column “am\_ba\_id”, :integer  
end  
end

def self.down  
drop\_table :am\_bas  
end  
end

and

class CreateAmApplications \< ActiveRecord::Migration  
def self.up  
create\_table :am\_applications do |t|  
t.column :business\_application\_name, :string  
t.column :created\_on, :datetime  
t.column :created\_at, :datetime  
t.column :updated\_on, :datetime  
t.column :updated\_at, :datetime  
t.column :lock\_version, :integer  
end  
end

def self.down  
drop\_table :am\_applications  
end  
end

My controller is

def new  
@am\_application = AmApplication.new  
@all\_bas = AmBa.find(:all, :order=\>“business\_area”)  
@selected = []  
end

def create  
@am\_application = AmApplication.new(params[:am\_application])  
if @am\_application.save  
flash[:notice] = ‘AmApplication was successfully created.’  
redirect\_to :action =\> ‘list’  
else

render :action =\> ‘new’  
end  
end

I do get a view on web which includes all the am\_bas rows in drop down  
box, but when I create a new record the join table  
am\_applications\_am\_bas is empty.

What gives? Am breaking my head over it for last 3 hours. Any help  
please

---

<div class="post-metadata">

**Author:** ![railrocks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c4cdca/32.png) [@railrocks](https://www.ruby-forum.com/u/railrocks)\
**Post date:** [November 21, 2006, 7:51am UTC](https://www.ruby-forum.com/t/join-table-not-getting-populated-habtm/71987/2 "2006-11-21T07:51:37Z")

</div>

I am also having a similar problem. I’m using Oracle as my database,  
and when I try to create a record in my join table, I get an  
ActiveRecord::StatementInvalid exception. It appears that the generated  
sql is trying to insert a value into an ‘id’ column. It originally  
complained about not finding a sequence, so I created one just to see  
what would happen. Unfortunately, my table, being a join table, doesn’t  
have an id column. It was created using migrations with the  
create\_table statement option :id =\> false. That’s why I’m getting an  
OCIError: ORA-00904: “ID”: invalid identifier error.

Does anyone know how to get AR to stop trying to insert an id into my  
join table? Is there something more than :id =\> false in the  
migrations?

Thanks,

-Anthony
