Where do I place the configuration for Act-as-taggable-on?
Asked Answered
P

1

12

I'm reading the act-as-taggable Github document, https://github.com/mbleigh/acts-as-taggable-on, and I want to force tags to be saved downcase. The instruction in the Configuration section says to add the line

ActsAsTaggableOn.force_lowercase = true

but I'm not quite sure where this would go.

In what file am I supposed to put this piece of code?

Thanks!

Paulettapaulette answered 26/4, 2012 at 0:59 Comment(2)
I guess you can create a file called acts_as_taggable_on_configuration.rb on initializers directory, and place all configuration in it. Remember to restart your application after create this file.Distributive
I had this error when my gem was too old... for example 2.2.2 gives the error, while 2.3.3 is good!Aphasia
I
13

You can create a custom initializer in config/initializers and put this line there.

Or alternatively, you can set this in config/application.rb:

module YourApp
  class Application < Rails::Application
    ActsAsTaggableOn.force_lowercase = true
  end
end
Irresolvable answered 6/6, 2012 at 11:25 Comment(1)
If you do a custom initializer, what do you declare the class, inheritance or wrapper as?Angiology

© 2022 - 2024 — McMap. All rights reserved.