Update FK_ID at validation/save time in activerecor

E

Eduardo Blumenfeld

I have:

------------------------
class Customer < ActiveRecord::Base
belongs_to :Customer_Type
end

class Customer_Type < ActiveRecord::Base
has_many :Customers
end
 
A

Ammar Ali

I have:

------------------------
class Customer < ActiveRecord::Base
=C2=A0 belongs_to :Customer_Type
end

class Customer_Type < ActiveRecord::Base
=C2=A0 has_many :Customers
end

ActiveRecord questions are better placed on the Rails mailing list,
but here's a hint:

type =3D CustomerType.find_by_name("Wholesale")

Ammar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,149
Messages
2,570,841
Members
47,388
Latest member
EarthaGilm

Latest Threads

Top