ruby on rails - initializer .rb file error happening -


i'm trying setup initializer fb file keep getting error after restarting rails app. here initializer file called mail_chimp.rb

code inside rb file

mailchimp.configure |config|   config.api_key = 'blabla' end 

error after restarting rails.

myproject/config/initializers/mail_chimp.rb:1:in `<top (required)>': uninitialized constant mailchimp (nameerror)     me/.rvm/gems/ruby-2.0.0-p0/gems/railties-4.0.0.rc1/lib/rails/engine.rb:609:in `block (2 levels) in <class: 

anyone know why i'm getting error. i'm new rails first time setting initializer file

the gem's namespace mailchimp, not mailchimp.

mailchimp.configure |config|   config.api_key = 'blabla' end 

but assumes gem linked above 1 you're working (you haven't specified otherwise).


edit: you've specified issue more clearly, need create own module. mailchimp doesn't exist, can't call configure , pass block it. 1 example implementation might be

module mailchimp   extend self    def api_key     "bla bla"   end end 

this let call mailchimp.api_key , "bla bla". there gems out sort of thing, best way set 'secret' info in environment variable. use dotenv. there this excellent read.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -