Answer the question
In order to leave comments, you need to log in
Transferring data from one model to another?
Hello, I'm using Ruby on Rails 5.2.3 and Mongoid 7.0
. I need to migrate :name and :image_url from User.rb to Profile.rb and there are empty fields in some posts, they don't need to be migrated.
User.rb
class User
include Mongoid::Document
field :name, type: String
field :image_url, type: String
has_many :profiles, dependent: :destroy
end
class Profile
include Mongoid::Document
field :name, type: String
field :image_url, type: String
belongs_to :user, touch: true
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question