title: Rails NoMethodError: undefined method `[]=' for nil:NilClass in production environment
body: <p>I am stuck on a very weird issue. I have developed and tested my rails application successfully in development environment, but in the proccess of get my site up and running on production environment i needed to run the <code>rake secret</code> command. Unfortunately, i faced the following error message:</p>
  
  <pre><code>rake aborted!
  NoMethodError: undefined method `[]=' for nil:NilClass
  /var/www/html/comigo/comigo/config/application.rb:31:in `&lt;class:Application&gt;'
  /var/www/html/comigo/comigo/config/application.rb:19:in `&lt;module:Comigo&gt;'
  /var/www/html/comigo/comigo/config/application.rb:18:in `&lt;top (required)&gt;'
  /var/www/html/comigo/comigo/Rakefile:4:in `require'
  /var/www/html/comigo/comigo/Rakefile:4:in `&lt;top (required)&gt;'
  /home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/rake_module.rb:28:in `load'
  /home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/rake_module.rb:28:in `load_rakefile'
  /home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:686:in `raw_load_rakefile'
  /home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:96:in `block in load_rakefile'
  /home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'
  /home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:95:in `load_rakefile'
  /home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:79:in `block in run'
  /home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'
  /home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:77:in `run'
  /home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/exe/rake:27:in `&lt;top (required)&gt;'
  /home/deplguerrabr/.rvm/gems/ruby-2.3.1/bin/rake:22:in `load'
  /home/deplguerrabr/.rvm/gems/ruby-2.3.1/bin/rake:22:in `&lt;main&gt;'
  /home/deplguerrabr/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
  </code></pre>
  
  <p>Searching on the web i was redirected to some related issues, but no one of those were strictly the same as mine. Here i enumerate some problems that probabily can give you a big picture of my project's environment:
  1)I'm using devise for authentication (version 3.4.1)
  2)This issue appears only in the production environment
  3)I have the same versions of ruby and rails in production and development 
  environment
  4)Here are the gems that i am using:</p>
  
  <pre><code>actionmailer (4.2.6)
  actionpack (4.2.6)
  actionview (4.2.6)
  activejob (4.2.6)
  activemodel (4.2.6)
  activerecord (4.2.6)
  activesupport (4.2.6)
  acts_as_votable (0.10.0)
  arel (6.0.3)
  autoprefixer-rails (6.4.1.1, 6.3.7, 6.3.6)
  bcrypt (3.1.11)
  bigdecimal (default: 1.2.8)
  binding_of_caller (0.7.2)
  bootstrap-sass (3.2.0.2)
  bootstrap-tagsinput-rails (0.4.2.1)
  bootsy (2.2.2)
  bson (3.2.6)
  bson_ext (1.5.1)
  builder (3.2.2)
  bundler (1.12.5)
  bundler-unload (1.0.2)
  bxslider-rails (4.2.5.1)
  byebug (9.0.5, 9.0.3)
  cancancan (1.14.0)
  carrierwave (0.11.2)
  carrierwave-mongoid (0.10.0, 0.9.0)
  client_side_validations (4.2.3)
  climate_control (0.0.3)
  cocaine (0.5.8)
  coffee-rails (4.1.1)
  coffee-script (2.4.1)
  coffee-script-source (1.10.0)
  commonjs (0.2.7)
  concurrent-ruby (1.0.2)
  countries (1.2.5)
  country_select (2.5.2)
  currencies (0.4.2)
  debug_inspector (0.0.2)
  devise (4.2.0, 4.1.1, 3.4.1)
  did_you_mean (1.0.0)
  erubis (2.7.0)
  execjs (2.7.0, 2.6.0)
  executable-hooks (1.3.2)
  faraday (0.9.2)
  faraday_middleware (0.9.2)
  fileutils (0.7)
  font-awesome-rails (4.6.3.0)
  gem-wrappers (1.2.7)
  geoip (1.4.0)
  globalid (0.3.7, 0.3.6)
  gmaps4rails (2.1.2)
  google_visualr (2.5.1)
  haml (4.0.7)
  hashie (3.4.4)
  httpauth (0.2.1)
  i18n (0.7.0)
  i18n_data (0.7.0)
  image-picker-rails (0.2.4)
  instagram (1.1.6)
  io-console (default: 0.4.5)
  jbuilder (2.6.0, 2.5.0, 2.4.1)
  jquery-migrate-rails (1.2.1)
  jquery-rails (4.2.1, 4.1.1)
  jquery-slick-rails (1.6.0.2)
  jquery-ui-rails (5.0.5)
  js_regex (1.0.14)
  json (default: 1.8.3)
  jwt (1.5.4, 1.5.1, 0.1.13)
  kaminari (0.16.3)
  less (2.6.0)
  less-rails (2.7.1)
  libv8 (3.16.14.15 x86_64-linux)
  loofah (2.0.3)
  mail (2.6.4)
  mime-types (3.1, 3.0)
  mime-types-data (3.2016.0521, 3.2016.0221)
  mimemagic (0.3.2, 0.3.1)
  mini_magick (4.5.1)
  mini_portile2 (2.1.0, 2.0.0)
  minitest (5.9.0, 5.8.3)
  mongo (2.1.0.beta)
  multi_json (1.12.1, 1.12.0)
  multi_xml (0.5.5)
  multipart-post (2.0.0)
  mysql2 (0.4.4)
  nested_form (0.3.2)
  net-telnet (0.1.1)
  nokogiri (1.6.8, 1.6.7.2)
  oauth (0.5.1)
  oauth2 (1.2.0, 1.1.0, 0.8.1)
  omniauth (1.3.1)
  omniauth-facebook (4.0.0, 3.0.0, 1.4.0)
  omniauth-oauth (1.1.0)
  omniauth-oauth2 (1.4.0, 1.0.3)
  omniauth-twitter (1.2.1)
  origin (2.2.0)
  orm_adapter (0.5.0)
  paperclip (5.0.0.beta2)
  passenger (5.0.28)
  pdf-core (0.6.1)
  pg (0.18.4)
  pkg-config (1.1.7)
  power_assert (0.2.6)
  prawn (2.1.0)
  prawn-table (0.2.2)
  prawnto_2 (0.2.6)
  psych (default: 2.0.17)
  rack (1.6.4)
  rack-pjax (0.8.0)
  rack-test (0.6.3)
  rails (4.2.6)
  rails-api (0.4.0)
  rails-deprecated_sanitizer (1.0.3)
  rails-dom-testing (1.0.7)
  rails-html-sanitizer (1.0.3)
  rails_12factor (0.0.3)
  rails_admin (0.8.1)
  rails_serve_static_assets (0.0.5)
  rails_stdout_logging (0.0.5)
  railties (4.2.6)
  rake (11.2.2, 11.1.2, 10.4.2)
  rdoc (4.2.2, default: 4.2.1)
  recaptcha (3.2.0)
  ref (2.0.0)
  regexp_parser (0.3.3)
  remotipart (1.2.1)
  responders (2.3.0, 2.2.0)
  rmagick (2.15.4)
  rubygems-bundler (1.4.4)
  rubygems-update (2.6.4)
  rvm (1.11.3.9)
  safe_yaml (1.0.4)
  sass (3.4.22)
  sass-rails (5.0.6, 5.0.5, 5.0.4)
  sdoc (0.4.1)
  simple_form (3.3.1, 3.2.1)
  sort_alphabetical (1.0.2)
  spring (1.7.2, 1.7.1)
  sprockets (3.7.0, 3.6.3, 3.6.0)
  sprockets-rails (3.2.0, 3.1.1, 3.0.4)
  test-unit (3.1.5)
  therubyracer (0.12.2)
  thor (0.19.1)
  thread_safe (0.3.5)
  tilt (2.0.5, 2.0.4)
  time_difference (0.4.2)
  ttfunk (1.4.0)
  turbolinks (5.0.1, 5.0.0, 2.5.3)
  turbolinks-source (5.0.0)
  twitter-bootswatch-rails (3.3.4.0)
  twitter-bootswatch-rails-helpers (3.3.2.0)
  tzinfo (1.2.2)
  uglifier (3.0.2, 3.0.0)
  underscore-rails (1.8.3)
  unicode_utils (1.4.0)
  warden (1.2.6)
  web-console (2.3.0)
  wysiwyg-rails (2.2.4)
  </code></pre>
  
  <p>Finaly, here is my config/application.rb code:</p>
  
  <pre><code>require File.expand_path('../boot', __FILE__)
  
  require "rails"
  # Pick the frameworks you want:
  require "active_model/railtie"
  require "active_job/railtie"
  # require "active_record/railtie"
  require "action_controller/railtie"
  require "action_mailer/railtie"
  require "action_view/railtie"
  require "sprockets/railtie"
  require "rails/test_unit/railtie"
  
  # Require the gems listed in Gemfile, including any gems
  # you've limited to :test, :development, or :production.
  Bundler.require(*Rails.groups)
  
  module Comigo
    class Application &lt; Rails::Application
      # Settings in config/environments/* take precedence over those specified here.
      # Application configuration should go into files in config/initializers
      # -- all .rb files in that directory are automatically loaded.
  
      # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
      # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
      # config.time_zone = 'Central Time (US &amp; Canada)'
  
      # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
      # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
      # config.i18n.default_locale = :de
      config.action_view.javascript_expansions[:defaults] = %w(jquery.min jquery_ujs)
    end
  </code></pre>
  
  <p>Thanks, i hope that anyone can help me. I am stuck in this problem for several hours!</p>