简体   繁体   中英

How do you configure a Rails Gem (TrueMail)

I'm trying to add TrueMail ( https://github.com/rubygarage/truemail ) to my Rails Application and in order for it work I need to configure it. However, I'm not sure where to create a file to add the configuration.

If you click on the link ( https://github.com/rubygarage/truemail ) and view the code just under "Setting global configuration" you'll see what I'm talking about. However, I have no idea where this needs to go.

Any assistance would be greatly appreciated.

Place it in config/initializers/truemail.rb . You can learn more about initializers at https://guides.rubyonrails.org/v2.3/configuring.html#using-initializers :

After it loads the framework plus any gems and plugins in your application, Rails turns to loading initializers. An initializer is any file of ruby code stored under /config/initializers in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks and plugins are loaded.

This is where almost every gem configuration is placed, and the naming convention is typically config/initializers/gem-name.rb , eg, if you were using a gem called superlogger that required configuration you would place it in config/initializers/superlogger.rb .

Note that since you're using Rails you likely do not need the following line:

require 'truemail'

Corey. It's pretty easy. For start using Truemail in your Rails application just follow next steps:

  1. Add gem 'truemail' line into your Gemfile
  2. Run bundle install
  3. Make file ./config/initializers/truemail.rb and add valid config follow with truemail documentation . Please note, you needn't add line with require 'truemail' , Rails loader will do it for you.

Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM