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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---
anthony-icZdIMMiY0Opv2MiSiIzJgC/G2K4zDHf@public.gmane.org
2006-Nov-21 06:49 UTC
Re: join table not getting populated habtm
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---