Here is a part of the struture : ==== Migration - create zones ... t.string :code_zone, :limit => 5 t.string :desc_zone, :limit => 40 t.string :tool_status, :limit => 1 ...
==== Model zone validates_uniqueness_of :code_zone has_many :regions ==== Migration - add zones ... Zone.create(:code_zone => 'EUROP', :desc_zone => 'Europe', :tool_status => 'A') Zone.create(:code_zone => 'NAMER', :desc_zone => 'North America', :tool_status => 'A') ... ==== Migration - create regions ... t.string :code_region, :limit => 5 t.string :desc_region, :limit => 40 t.string :tool_status, :limit => 1 t.references :code_zone ... ==== Model region validates_uniqueness_of :code_region belongs_to :zone ==== Migration - add regions ... Region.create(:code_region => 'AFRIC', :desc_region => 'Africa', :tool_status => 'A', :code_zone => 'INTER') Region.create(:code_region => 'ASIA', :desc_region => 'Asia Pacific', :tool_status => 'A', :code_zone => 'ASIA') Region.create(:code_region => 'USA', :desc_region => 'USA', :tool_status => 'A', :code_zone_id => 'NAMER') ... I would like to add a find method which return the id of the code zone name entered within Region.create(...) Is it possible to rewrite the create method used to create entries in the database ? -- 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

