[英]Rails 3.1 pre Migration problem
Now i am upgrade the rails 3.0.7 to rails 3.1 pre version. 现在我将rails 3.0.7升级到rails 3.1 pre版本。 When i am creating a sample project it works fine. 当我创建一个示例项目时,它工作正常。 After creating a scaffold i am try to migrate, but it gives me the rake aborted! 创建一个脚手架后,我尝试迁移,但它让我的耙子中止了! message. 信息。
Here my code 在这里我的代码
rails g scaffold product name:string price:decimal category:string
invoke active_record
create db/migrate/20110517090853_create_products.rb
create app/models/product.rb
invoke test_unit
create test/unit/product_test.rb
create test/fixtures/products.yml
route resources :products
invoke scaffold_controller
create app/controllers/products_controller.rb
invoke erb
create app/views/products
create app/views/products/index.html.erb
create app/views/products/edit.html.erb
create app/views/products/show.html.erb
create app/views/products/new.html.erb
create app/views/products/_form.html.erb
invoke test_unit
create test/functional/products_controller_test.rb
invoke helper
create app/helpers/products_helper.rb
invoke test_unit
create test/unit/helpers/products_helper_test.rb
create app/assets/stylesheets/scaffold.css.scss
invoke assets
create app/assets/javascripts/products.js.coffee
create app/assets/stylesheets/products.css.scss
rake db:migrate
== CreateProducts: migrating =================================================
-- create_table(:products)
-> 0.0053s
== CreateProducts: migrated (0.0054s) ========================================
rake aborted!
An error has occurred, all later migrations canceled:
undefined method `rows' for nil:NilClass
(See full trace by running task with --trace)
I am using ruby 1.9.2 and xampp. 我使用的是ruby 1.9.2和xampp。
Can any one know what is the problem? 任何人都可以知道问题是什么吗?
I had the same problem using mysql2 v0.2.6 as database adapter. 我使用mysql2 v0.2.6作为数据库适配器时遇到了同样的问题。
I've tried to solve it updating mysql2 to latest version 0.3.2, but I could not compile this gem on Windows. 我试图解决它更新mysql2到最新版本0.3.2,但我无法在Windows上编译此gem。 But I still believe that recent version of mysql2 might work. 但我仍然认为最新版本的mysql2可能有效。 Currently I use "pg" gem as postgres adapter for DB and it works fine with Rails 3.1.pre 目前我使用“pg”gem作为DB的postgres适配器,它可以与Rails 3.1.pre一起使用
This worked for me. 这对我有用。 I changed Gemfile to use the github repo: 我更改了Gemfile以使用github repo:
gem 'mysql2', :git => 'git://github.com/brianmario/mysql2.git'
Then ran a bundle install. 然后运行捆绑安装。 I still got an error after this about libmysqlclient.18.dylib being missing, which I fixed by running (your paths may vary): 关于libmysqlclient.18.dylib丢失之后我仍然遇到错误,我通过运行修复了(你的路径可能会有所不同):
install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib ~/.rvm/gems/ruby-1.9.2-p180/bundler/gems/mysql2-a1ddafaf8b31/lib/mysql2/mysql2.bundle
I just ran into this issue on my Windows 7 computer and was able to resolve it, thanks to http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html . 我刚刚在我的Windows 7计算机上遇到了这个问题并且能够解决它,感谢http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html 。 I have devkit already installed, and this is what did it for me: 我已经安装了devkit,这就是为我做的:
gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.1\lib\opt" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.1\include"'
This installed version 0.3.7 of the MySQL adapter, and I was able to run my migrations successfully. 这个安装了0.3.7版本的MySQL适配器,我能够成功运行我的迁移。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.