Capitalising namespaces in Rails
A common practice when building Rails API's is to namespace the logic under an Api
directive, having a bit of an OCD problem I couldn't stand looking at a non-capitalised acronym.
Luckily for us (me?), we can use Rail's inflections to fix this little issue.
ActiveSupport::Inflector.inflections do |inflect|
inflect.acronym 'API'
end
Now I can look at my code without feeling anxiety!
class API::UsersController < ApplicationController; end
Written by Gus Bonfant
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#