Uninitialized constant Project (NameError) in setting up Figaro gem

ruby-on-rails, ruby-on-rails-3.2

Solution

It seems like the name of your application is not the same in the different places it needs to appear in. Check the following files and see if they contain either `Projectmanagement::Application` or `Railsapp::Application`:

- config/application.rb (Actually initializes the constant)

- config/environment.rb

- config/environments/development.rb

- config/environments/production.rb

- config/environments/test.rb

- config/initializers/secret_token.rb

- config/initializers/session_store.rb

- config/mongoid.yml (if using Mongoid)

- config/routes.rb

- config.ru

- Rakefile

- app/views/layouts/application.html.erb, in title tag

Then pick a name (either `Projectmanagement` or `Railsapp`) and change all the names in the above files so they match. That should resolve the uninitialized constant error you are having.

Problem

I updated a Rails 2.3 app to 3.2 and it seemed to be a pretty simple process but when setting up the Figaro gem I came across this error: ``` C:\Sites\JustManage>rails generate figaro:install C:/Sites/JustManage/config/environment.rb:5:in `<top (required)>': uninitialized constant Projectmanagement (NameError) from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 /lib/rails/application.rb:103:in `require_environment!' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 /lib/rails/commands.rb:25:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>' ``` Here is what my environment.rb looks like: ``` # Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Projectmanagement::Application.initialize! ``` Here is my application.rb file: ``` require File.expand_path('../application', __FILE__) require 'rails/all' if defined?(Bundler) Bundler.require(*Rails.groups(:assets => %w(development test))) end module Railsapp class Application < Rails::Application config.encoding = "utf-8" config.filter_parameters += [ :password, :password_clear, :password_verify ] config.assets.enabled = true config.assets.version = '1.0' end end ``` I've never run into this error before and don't know why it's happening.

Original source