demonchand
demonchand

Reputation: 11451

Rails 3.1 pre Migration problem

Now i am upgrade the rails 3.0.7 to rails 3.1 pre version. 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.

Can any one know what is the problem?

Upvotes: 4

Views: 2253

Answers (3)

RickTi
RickTi

Reputation: 101

This worked for me. I changed Gemfile to use the 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):

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

Upvotes: 3

Jeremy Thomas
Jeremy Thomas

Reputation: 479

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

Upvotes: 0

BitOfUniverse
BitOfUniverse

Reputation: 6021

I had the same problem using mysql2 v0.2.6 as database adapter.
I've tried to solve it updating mysql2 to latest version 0.3.2, but I could not compile this gem on Windows. But I still believe that recent version of mysql2 might work. Currently I use "pg" gem as postgres adapter for DB and it works fine with Rails 3.1.pre

Upvotes: 6

Related Questions