title: Moving admin-related files out of their models and controller folders and into a separate admin folder in Rails. How to organize this code?
body: <p>I am working on a legacy app with 100s of related admin models, controllers, services, jobs, etc. We decided to move all of these files in a folder at the top-level of the app directory called admin. So our ideal file structure would be:</p>
  
  <p><code>app/admin/models/admin.rb</code>
  <code>app/admin/controllers/admin_controller.rb</code>
  <code>app/admin/services/admin_service_of_some_kind.rb</code>
  <code>app/admin/models/audit.rb</code>
  <code>etc</code></p>
  
  <p>We want the call sites in our code to be:</p>
  
  <p><code>Admin::Admin.create...</code>
  <code>Admin::AdminService.retrieve_all_audit_logs...</code>
  <code>Admin::Audit.scope_by_admin...</code>
  <code>etc</code></p>
  
  <p>The problem is that after reading these links:</p>
  
  <p><a href="http://urbanautomaton.com/blog/2013/08/27/rails-autoloading-hell/" rel="nofollow">http://urbanautomaton.com/blog/2013/08/27/rails-autoloading-hell/</a>
  <a href="http://guides.rubyonrails.org/autoloading_and_reloading_constants.html" rel="nofollow">http://guides.rubyonrails.org/autoloading_and_reloading_constants.html</a></p>
  
  <p>I understand that Rails infers file path names from the constants. So if I want to call <code>Admin::AdminService.some_task</code>... Rails will believe the Admin constant and the nested AdminService constant would exist in a file at (assuming that app/admin is autoloaded... which I believe it is) <code>app/admin/admin_service.rb</code> which is not true... they exist in <code>app/admin/services/admin_service.rb</code>. </p>
  
  <p>How can I make this happen given that I want the call site to be <code>Admin::AdminService.some_task</code>?</p>
  
  <p>Given the folder structure of <code>app/admin/services/admin_service.rb</code>, the call site would have to be <code>Services::AdminService.some_task</code> right? (this assumes that <code>app/admin</code> is autoloaded) right? However,  this is not what I want.</p>