Linking two tables generated from "rails generate Scaffold" (New to Ruby on Rails) -


i save person's information education, address, etc database tables.

if generate person table(with education) using scaffold - id automatically generated primary key.

i generate table called address same person using scaffold. how can link id of address table id of person table?

you want person have_many addresses -see rails guide more on associations http://guides.rubyonrails.org/association_basics.html#the-has-many-association

you can scaffold doing

rails g scaffold address person:references line1:string city:string etc 

this generate model, address, foreign key person_id person belongs to.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -