What's the best way to add kinks in a Rails plugin?

I'm writing a plugin that needs some kinks of its own. Using 2.3 rails that have blown motors where should I place my kinks?

+1


a source to share


2 answers


I would recommend adding a separate file (inflections.rb) to your plugins lib. You should be able to load the inflections.rb file from the plugin by adding the following to the top of the plugin Ruby file.

require 'inflections"

      



Your inflections.rb file should follow the format shown as an example in new Rails projects:

# Sample Inflections    
# ActiveSupport::Inflector.inflections do |inflect|
#   inflect.plural /^(ox)$/i, '\1en'
#   inflect.singular /^(ox)en/i, '\1'
#   inflect.irregular 'person', 'people'
#   inflect.uncountable %w( fish sheep )
# end

      

+2


a source


UPDATE : For those who have the same problem but are using Rails 5, here is the correct answer.

Do not place the inflections.rb

file in a folder plugin/lib

, but in a folder plugin/config/initializers

.



Then just write your kinks (e.g. cliché / cliché):

ActiveSupport::Inflector.inflections do |inflect|
    inflect.irregular 'cliche', 'cliches'
end

      

0


a source







All Articles