*在继续这个之前,我将更好地学习Rails 3.1。感谢大家的帮助:我学到了很多东西! *
我正在尝试创建一个基于Gullery的在线产品组合,但我一开始就陷入困境:我无法创建数据库。当我运行'rake db:create'时,我收到以下错误:
rake aborted!
C:\ Sites \ gullery / RakeFile:14:语法错误,意外$ end,期待keyword_end
当我完整追踪时,我明白了:
C:\ Sites \ gullery> rake db:create --trace
rake aborted!
C:/ Sites / gullery / Rakefile:14:语法错误,意外$ end,期待keyword_e ND
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_ module.rb:25:在'load'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_ module.rb:25:在`load_rakefile'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:501:在`raw_load_rakefile'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:82:在load_rakefile中的“块”
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:133:在`standard_exception_handling'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:81:在`load_rakefile'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:65:在“阻止运行”中
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:133:在`standard_exception_handling'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:63:在'run'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:在 `'
C:/RailsInstaller/Ruby1.9.2/bin/rake:19:in"load'
C:/RailsInstaller/Ruby1.9.2/bin/rake:19:in''
当我在Google上搜索“语法错误,意外的$ end,期待keyword_end”时,答案显示我错过了某个地方。不幸的是,我没有经验知道丢失了哪个文件。这是否是正确的问题?如果是这样,我应该在哪里看?如果没有,实际发生了什么?
我正在使用Ruby on Rails 3.0,Ruby 1.9.2和mySQL。
提前致谢!
编辑:C:\ Sites \ gullery \ Rakefile:
的内容# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/switchtower.rake, and they will automatically be available to Rake. require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rdoc/task' RDoc::Task.new do |rdoc| require 'tasks/rails' # Fail if unit tests fail task :default => [:test_units, :test_functional]
编辑2:在Rakefile中添加“end”消除了语法错误,但我仍无法使用数据库。
新的Rakefile:
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/switchtower.rake, and they will automatically be available to Rake. require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rdoc/task' RDoc::Task.new do |rdoc| end require 'tasks/rails' # Fail if unit tests fail task :default => [:test_units, :test_functional]
新错误/追踪:
C:\Sites\gullery>rake db:create --trace WARNING: 'require 'rake/rdoctask'' is deprecated. Please use 'require 'rdoc/tas k' (in RDoc 2.4.2+)' instead. at C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rak e/rdoctask.rb C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/rdoc/task.rb:30: warning: already ini tialized constant Task rake aborted! Don't know how to build task 'db:create' C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task_ manager.rb:49:in `[]' C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:115:in `invoke_task' C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:94:in `block (2 levels) in top_level' C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:94:in `each' C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:94:in `block in top_level' C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:133:in `standard_exception_handling' C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:88:in `top_level' C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:66:in `block in run' C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:133:in `standard_exception_handling' C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli cation.rb:63:in `run' C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `' C:/RailsInstaller/Ruby1.9.2/bin/rake:19:in `load' C:/RailsInstaller/Ruby1.9.2/bin/rake:19:in `'
答案 0 :(得分:0)
我正在运行Rails 3.1,我的Rakefile看起来像这样:
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
V0100::Application.load_tasks
V0100是我的应用程序名称,对应于您的“gullery”。