When Mobility is loaded for ActiveRecord, it includes Mobility::ActiveRecord module
|
model_class.include(ActiveRecord) if model_class < ::ActiveRecord::Base |
If the ActiveRecord::Base subclass that now includes Mobility did something like the following before:
class MyModel < ActiveRecord::Base
def my_method
ActiveRecord::Base.uncached do
# some code
end
end
end
It will get an exception raised:
NameError:
uninitialized constant Mobility::ActiveRecord::Base
It will get an exception because ActiveRecord is found on Mobility module first (the original ActiveRecord from rails is further down in the ancestors chain.
The fix on the user's side would be to qualify top level lookup with ::ActiveRecord but I don't know how happy the users of Mobility would be if they had to do it.
Another would be to rename the ActiveRecord module in Mobility, which would kind of diminish the descriptiveness.
Do you have other suggestions on how to approach this issue?
When Mobility is loaded for ActiveRecord, it includes
Mobility::ActiveRecordmodulemobility/lib/mobility.rb
Line 86 in b001a29
If the
ActiveRecord::Basesubclass that now includesMobilitydid something like the following before:It will get an exception raised:
It will get an exception because
ActiveRecordis found onMobilitymodule first (the originalActiveRecordfrom rails is further down in the ancestors chain.The fix on the user's side would be to qualify top level lookup with
::ActiveRecordbut I don't know how happy the users of Mobility would be if they had to do it.Another would be to rename the
ActiveRecordmodule in Mobility, which would kind of diminish the descriptiveness.Do you have other suggestions on how to approach this issue?