This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/config/initializers/mongo.rb

28 lines
691 B
Ruby

MongoMapper.connection = Mongo::Connection.new('localhost', 27017)
MongoMapper.database = "r4-#{Rails.env}"
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
MongoMapper.connection.connect_to_master if forked
end
end
module MongoMapper::Document::ClassMethods
def key_i18n(key, *options)
VALID_LOCALES.each do |locale|
key "#{key.to_s}_#{locale}".to_sym, *options
end
define_method(key) do
self.send("#{key.to_s}_#{I18n.locale}")
end
define_method("#{key}=") do |value|
VALID_LOCALES.each do |locale|
self.send("#{key.to_s}_#{locale}=", value)
end
end
end
end