Rails 3.1 pre Migration Problem

Now I upgrade rails 3.0.7 to rails 3.1 to version. When I create a sample project, it works fine. After creating the scaffold, I try to migrate, but it gives me the rake canceled! message.

Here is 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.

Does anyone know what the problem is?

+4
source share
3 answers

I had the same problem as mysql2 v0.2.6 as a database adapter.
I tried to solve this problem by updating mysql2 to the latest version 0.3.2, but I could not compile this stone on Windows. But I still think the latest version of mysql2 might work. I am currently using "pg" gem as a postgres adapter for DB and it works fine with Rails 3.1.pre

+6
source

It worked for me. I modified the gemfile to use the github repo:

 gem 'mysql2', :git => 'git://github.com/brianmario/mysql2.git' 

Then the package was installed. After that, I still get the error that libmysqlclient.18.dylib is missing, and I fixed it (your paths may differ):

 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 
+3
source

I just ran into this problem on my Windows 7 computer and was able to solve it thanks to 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:

 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 successfully complete my migrations.

0
source

All Articles