I'm following the Hartl book, Chapter 3, where we begin with static pages. We are told to do:
$ git checkout -b static-pages
No issues with that. Then, we are told to do the command:
$ rails generate controller StaticPages home help --no-test-framework
When I do that, I get this in the command line:
sample_app/config/application.rb:31:in `<top (required)>': undefined local variable or method `config' for main:Object (NameError)
from /Users/NormalUse/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.5/lib/rails/commands.rb:43:in `require'
from /Users/NormalUse/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.5/lib/rails/commands.rb:43:in `<top (required)>'
from bin/rails:8:in `require'
from bin/rails:8:in `<main>'
Line 31 of config/application.rb:31
is this:
config.assets.initialize_on_precompile = false
which I added because of Heroku issues. I tried taking out that line, and then it threw about 50 more errors.
Here is the gemfile we are supposed to be using
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.5'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
Here is the full application.rb file:
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_model/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 SampleApp
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
config.assets.initialize_on_precompile = false
Any ideas that I can try?
EDIT: After moving this: config.assets.initialize_on_precompile = false
into the class like was suggested below, I get a lot of errors!
Here are the first 5 lines of errors: /Users/NormalUse/ror/sample_app/config/environments/development.rb:1:in `<top (required)>': undefined method `configure' for #<SampleApp::Application:0x007fa2178a73a0> (NoMethodError)
from /Users/NormalUse/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `require'
from /Users/NormalUse/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `block in require'
from /Users/NormalUse/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:214:in `load_dependency'
from /Users/NormalUse/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `require'
from /Users/NormalUse/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/gems/railties-4.0.5/lib/rails/engine.rb:591:in `block (2 levels) in <class:Engine>'
EDIT EDIT: I just want to say thank you very much for those who helped me with this. I can't imagine how tough and frustrating it can be trying to help those of us who are REALLY new to all of this. I'm cruising through now that we've established that two different installed versions of Rails were conflicting.