我有一个user table,contains例如user registration details,username和password...email
我怎么能add... ?profile tablestore name, country, age etc
我只是简单地create选择数据还是使用?tableuse JOINis there another way to do thisRuby on Rails
我有一个user table,contains例如user registration details,username和password...email
我怎么能add... ?profile tablestore name, country, age etc
我只是简单地create选择数据还是使用?tableuse JOINis there another way to do thisRuby on Rails
使用迁移将这些列添加到用户模型。从它的声音来看,我认为您实际上不需要为这些属性创建一个单独的模型。
您的迁移可能看起来像
rails g migration AddProfileDataToUsers
class AddProfileDataToUsers < ActiveRecord::Migration
change_table :users do |t|
t.add_column :name, :string
t.add_column :country, :string...
#whatever else you want to add to the user model here
end
end
然后,您可以通过执行@user.country 或类似的操作来根据需要提取数据。希望这可以帮助