2015-07-10 69 views
1

我正在使用Ruby 2.2.2和Rails 4.2.3。嘗試bundle exec時未定義的方法'strong'rake db:migrate

我做的命令是:

rails generate scaffold User name:string email:string 
bundle exec rake db:migrate 

我得到的錯誤是:

rake aborted! 
StandardError: An error has occurred, this and all later migrations canceled: 

undefined method `strong' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x00000005b72028>/home/clemant/tutorials/test2/db/migrate/20150709221657_create_users.rb:5:in `block in change' 

我的遷移文件:

class CreateUsers < ActiveRecord::Migration 
    def change 
    create_table :users do |t| 
     t.string :name 
     t.strong :email 

     t.timestamps null: false 
    end 
    end 
end 

我的database.yml文件是:

# SQLite version 3.x 
# gem install sqlite3 
# 
# Ensure the SQLite 3 gem is defined in your Gemfile 
# gem 'sqlite3' 
# 
default: &default 
    adapter: sqlite3 
    pool: 5 
    timeout: 5000 

development: 
    <<: *default 
    database: db/development.sqlite3 

# Warning: The database defined as "test" will be erased and 
# re-generated from your development database when you run "rake". 
# Do not set this db to the same as development or production. 
test: 
    <<: *default 
    database: db/test.sqlite3 

production: 
    <<: *default 
    database: db/production.sqlite3 

任何想法如何解決這個問題?

+0

請發表您的遷移文件,並database.yml文件 – Pavan

+0

是拿在database.yml中一看,就好像錯誤消息你有什麼錯在這裏。 –

+0

它很明顯,你需要改變t.strong:電子郵件 t.string:電子郵件 –

回答

1

在您的遷移文件中,您已寫入:t.strong :email

應糾正如下:

t.string :email 
+0

非常棒! :) – Pavan

相關問題