Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Simple Ruby on Rails Application Creating an Authentication System Installing Devise

jarrod Reeves
jarrod Reeves
6,357 Points

My Treebook application isn't working?

Hi I was working on Treebook project last night and all was working fine. But I went to do a little tonight and I have a bunch of errors when trying to start the rails server.

Here is what I am getting when I type rails server into the command prompt. (windows 8)

C:\Users\Jazza\Documents\Projects\treebook>rails server
C:/Users/Jazza/Documents/Projects/treebook/config/application.rb:5:in `<top (req
uired)>': undefined local variable or method `config' for main:Object (NameError
)
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/comman
ds/commands_tasks.rb:79:in `require'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/comman
ds/commands_tasks.rb:79:in `block in server'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/comman
ds/commands_tasks.rb:76:in `tap'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/comman
ds/commands_tasks.rb:76:in `server'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/comman
ds/commands_tasks.rb:40:in `run_command!'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.6/lib/rails/comman
ds.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

I had a look in the application.rb file and could not find any problems.

require File.expand_path('../boot', __FILE__)

require 'rails/all'

config.assets.initialize_on_precompile = false

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Treebook
  class Application < 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 & 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
  end
end

Thanks. !

1 Answer

I would try just leaving it out. My thinking is that it doesn't seem to be a requirement and I bet you're using a higher version or rails, I've been using something around 4.1.5 or something recently, and his console says,

'if you are deploying on rails 3.1 to heroku, you may want to set:

config.assets.initialize_on_precompile'

jarrod Reeves
jarrod Reeves
6,357 Points

Tried it and didn't work :(