First, I don’t really understand the logic to do that. But, OK, it’s
up to you to define it.
If you have the attribute 'first_name defined both in the two models,
you should do something like this:
model name1 - ( has_one :name2)
model name2 = (belongs_to :name)
If you mean that you have two tables, both with a ‘name’ column and
you want the same data in both columns then I advise against this. It
is generally a bad idea to have the same data in two tables in the
database, you have to be very careful to keep them the same when the
name is edited for example. Also there is no need since you have
defined a relationship between the tables. So if you have a name1
record in @name1 and the name column is in table name2 then you can
say @name1.name2.name to get the name.
Colin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.