I have some structure
dokuwiki.rb
require 'dokuwiki/exception.rb'
module Dokuwiki
...
dokuwiki/api/connection.rb
module Dokuwiki
module API
class Connection
...
Now, when I try to call Dokuwiki::API::Connection.new
from a controller (without any require
), Rails default constants autoloading fails. I believe this is because the ::API
module should have a folder named /a_p_i/
instead of /api/
but that's ugly.
Of course I could require 'dokuwiki/api/connection.rb', in the main '/lib/dokuwiki.rb' file, but then it wouldn't reload this class automatically (which is kinda annoying in a dev context)
What can I do to keep the nice /api/
folder name and be able to do some live modifications to /lib/dokuwiki/api/connection.rb
without having to restart my server ?
There's a file called config/initializers/inflections.rb
.
Add in it
ActiveSupport::Inflector.inflections do |inflect|
inflect.acronym 'API'
end
and the API namespace will be available as a directory called api
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With