This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Structure for inheritance | |
# app/models/parent/base.rb | |
class Parent::Base | |
include Mongoid::Document | |
end | |
# app/models/parent/first_child.rb | |
class FirstChild < Parent::Base | |
# fields needed for first child |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Person.all.each do |p| | |
arr = [p.first_name, p.last_name] | |
if p.middle_name.present? | |
arr.insert(1, p.middle_name) | |
end | |
p._keywords = arr | |
p.save | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person | |
include Mongoid::Document | |
field :name, :type => String | |
field :age, :type => Integer | |
field :address, :type => Hash | |
end | |
/***** ADDING THROUGH CONSOLE ******/ |
NewerOlder