Reputation: 2409
I'm trying to keep the application as neat and tidy as possible because it could get quite large. Already a few days into it I've noticed the following pattern in the models:
models/
prefix_file.rb
prefix_file2.rb
prefix_file3.rb
file.rb
prefix2_file.rb
prefix2_file2.rb
Is there anyway to organise the models directory into subfolders?
Upvotes: 0
Views: 493
Reputation: 19839
You can namespace your files in directories and use modules.
For example
models/
prefix/
file.rb
file2.rb
file3.rb
prefix2/
file.rb
file2.rb
file.rb
Then inside your files within the directories you would have something like
models/prefix/file.rb
module Prefix
class File < ActiveRecord::Base
end
end
To use them you would need to have code like this Prefix::File.some_method
Upvotes: 2