Rails 数据库表无法生成

iamfangfang123 · 2013年01月07日 · 最后由 iamfangfang123 回复于 2013年02月27日 · 5246 次阅读

IDE 是 netbeans7.2.1 创建项目后 localhost:3000 页面显示如下: About your application’s environment Ruby version 1.8.7 (i386-mingw32) RubyGems version 1.8.24 Rails version 2.0.2 Active Record version 2.0.2 Action Pack version 2.0.2 Active Resource version 2.0.2 Action Mailer version 2.0.2 Active Support version 2.0.2 Application root E:/netbeansWorkSpace/RailsApplication2 Environment development Database adapter mysql 在 netbeans 创建的项目上右键 migrate database-》to current version 出现 "db:migrate" does not task 错误,不能生成数据库表。请问我应该怎么解决? 其中生成的 model 类为 class Post < ActiveRecord::Base end migrate 下的 class CreatePosts < ActiveRecord::Migration def self.up create_table :posts do |t| t.column "title",:string t.timestamps end end

def self.down drop_table :posts end end

还是命令行吧,ide 出问题很难搞的。

数据库连接是正确的

1 楼的意思是,用 sql 语句自己创建数据库表?

命令行上执行:rake db:migrate

控制台执行 rake db:migrate 后出现这样的错误 rake aborted! Unrecognized --trace option 'race' C:/Ruby187/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:508:in se lect_trace_output' C:/Ruby187/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:466:inst andard_rake_options' C:/Ruby187/lib/ruby/1.8/optparse.rb:1298:in call' C:/Ruby187/lib/ruby/1.8/optparse.rb:1298:inparse_in_order' C:/Ruby187/lib/ruby/1.8/optparse.rb:1254:in catch' C:/Ruby187/lib/ruby/1.8/optparse.rb:1254:inparse_in_order' C:/Ruby187/lib/ruby/1.8/optparse.rb:1248:in order!' C:/Ruby187/lib/ruby/1.8/optparse.rb:1339:inpermute!' C:/Ruby187/lib/ruby/1.8/optparse.rb:1360:in parse!' C:/Ruby187/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:518:inha ndle_options' C:/Ruby187/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:81:in ini t' C:/Ruby187/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:160:inst andard_exception_handling' C:/Ruby187/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:79:in ini t' C:/Ruby187/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:71:inrun ' C:/Ruby187/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:160:in st andard_exception_handling' C:/Ruby187/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:70:inrun ' C:/Ruby187/lib/ruby/gems/1.8/gems/rake-10.0.3/bin/rake:33 C:/Ruby187/bin/rake:23:in `load' C:/Ruby187/bin/rake:23

建议换 linux 吧,windows 听说不太 OK。

还是在 windows 上,最后可以了,只是我中间装过 devkit,然后缺的的 gem 包也都一一 gem install xxx 了

需要 登录 后方可回复, 如果你还没有账号请 注册新账号