hi friends, I am new to ruby and i need a help from any one of u. I have got four tables and all i have to get the thing is i need to take the Id from one table and pass it in to the another table. Similarly in the descending order, one to two, to three, to four. ie , first tables primary key is the second one''s foreign key. second table,first table primary key is the third tables primary key and so on.... Now i have to get that functionality in the manner like, in one form i need to get four labels where in i can provide and store in to the database.... and on submitting, it will lead us to the listing page, where in i had maintained drop down list. But the thing is i am getting all the contents. I have to get only those first table id contents from four tables , through foreign reference. In the database also it is not passing that id values in to the child tables. def new @country = Country.new @state = State.new @city = City.new @category = Category.new end def create @country=Country.new(params[:country]) @state=State.new(params[:state]) #@country.states.create(params[:id]) @city=City.new(params[:city]) #@country.cities.create(params[:id]) #@state.cities.create(params[:id]) @category=Category.new(params[:category]) #@country.categories.create(params[:id]) #@state.categories.create(params[:id]) #@city.categories.create(params[:id]) @country.save @state.save @city.save @category.save redirect_to :action =>''list'' end def list end and the models are class Country < ActiveRecord::Base has_many :states has_many :cities end class State < ActiveRecord::Base belongs_to :country has_many :cities end class City < ActiveRecord::Base belongs_to :state belongs_to :country end class Category < ActiveRecord::Base belongs_to :state belongs_to :country belongs_to : city end and the view files are: list.rhtml <align> <form name="combo"> <h4>Select Country<br><%= select(''name'', ''id'', Country.find_all.collect {|country| country.name}) %><br> <h4>Select State<br><%= select(''name'', ''id'', State.find_all.collect {|state| state.name}) %><br> <h4>Select City<br><%= select(''name'', ''id'', City.find_all.collect {|city| city.name}) %><br> <h4>Select Category<br><%= select(''name'', ''id'', Category.find_all.collect {|category| category.name}) %><br> new.rhtml <%= start_form_tag :action => ''create'' %> <h4>Country<br><%= text_field ''country'', ''name'' %></br> <h4>State<br><%= text_field ''state'', ''name'' %></br> <h4>City<br><%= text_field ''city'', ''name'' %></br> <h4>Category<br><%= text_field ''category'', ''name'' %></br> <%= submit_tag "Add" %> <%= end_form_tag %> please have a look in to my coding and help me out with some suggestions or modifications Expecting a help from rubians thank u -- 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?hl=en -~----------~----~----~----~------~----~------~--~---