I have a model app/models/my_model.rb
class MyModel < ActiveRecord::Base
...
end
I have another class overridden from MyModel inside app/models/my_model_r_r.rb
class MyModelRR < MyModel
...
end
I have a helper file in app/helpers/v2/some_helper.rb where I want to use MyModelRR
module V2::SomeHelper
# Want to use MyModelRR
end
I tried using:
# Inside some_helper.rb
require 'app/models/my_model_r_r.rb
# Throws error --
<home>/.rvm/gems/ruby-2.1.4/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- app/models/my_model_r_r.rb (LoadError)
After this, I moved my_model_r_r.rb inside app/models/read_only, and added this in application.rb:
config.autoload_paths += Dir["#{config.root}/app/models/read_only"]
# Throws error:
NameError (uninitialized constant V2::SomeHelper::MyModelRR):
Any ideas how to solve this?
I'm using Rails 3.2 running on Ruby 1.9.3 (same error with Ruby 2.1)
EDIT: require 'app/models/my_model_r_r.rb'
works perfectly fine when I switch to Ruby 1.8.7.