3
我試圖運行下面的命令:未初始化的常量SampleApp(NameError)
rails generate controller StaticPages home help --no-test-framework
,我不斷收到此錯誤:
/Users/josh/Desktop/RoR/rails_app/config/initializers/secret_token.rb:27:in `<top (required)>': uninitialized constant SampleApp (NameError)
這是我的secret_token.rb文件
require 'securerandom'
def secure_token
token_file = Rails.root.join('.secret')
if File.exist?(token_file)
# Use the existing token.
File.read(token_file).chomp
else
# Generate a new token and store it in token_file.
token = SecureRandom.hex(64)
File.write(token_file, token)
token
end
end
SampleApp::Application.config.secret_key_base = secure_token
在'Rake文件什麼'?我想檢查應用名稱是否匹配。 – HungryCoder
您的應用名爲SampleApp,還是稱爲RailsApp? – trh
比較'config/application.rb'中應用的名稱。這可能與'SampleApp'有所不同! – ck3g