Rails db:migrate 中止 "undefined local variable or method `limit'" 为什么?
Rails db:migrate aborted with "undefined local variable or method `limit'" why?
对不起我的英语。
我搜索了该站点,但找不到解决方案。
当我尝试使 rails db: migrate 给我这个错误时:
C:\PW\Sites\grota>rails db:migrate
== 20170209014957 CreateWholesalers: migrating ================================
-- create_table(:wholesalers)
-- limit()
rails aborted!
StandardError: An error has occurred, all later migrations canceled:
undefined local variable or method `limit' for # <CreateWholesalers:0x00000006bfc6a0>
C:/PW/Sites/grota/db/migrate/20170209014957_create_wholesalers.rb:7:in `block in change'
C:/PW/Sites/grota/db/migrate/20170209014957_create_wholesalers.rb:3:in `change'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
NameError: undefined local variable or method `limit' for # <CreateWholesalers:0x00000006bfc6a0>
C:/PW/Sites/grota/db/migrate/20170209014957_create_wholesalers.rb:7:in `block in change'
C:/PW/Sites/grota/db/migrate/20170209014957_create_wholesalers.rb:3:in `change'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
这是我的迁移代码:
class CreateWholesalers < ActiveRecord::Migration[5.0]
def change
create_table :wholesalers do |t|
t.string "brand_name", :limit => 25
t.string "username", :limit => 25
t.string "password_digest"
t.string "email", limit => 50
t.decimal "latitude"
t.decimal "longitude"
t.timestamps
end
end
end
提前致谢。
此行导致错误(缺少 :
):
t.string "email", :limit => 50
Cristiano Morais 应标记为正确答案。这是一个拼写错误。缺少 :
对不起我的英语。 我搜索了该站点,但找不到解决方案。 当我尝试使 rails db: migrate 给我这个错误时:
C:\PW\Sites\grota>rails db:migrate
== 20170209014957 CreateWholesalers: migrating ================================
-- create_table(:wholesalers)
-- limit()
rails aborted!
StandardError: An error has occurred, all later migrations canceled:
undefined local variable or method `limit' for # <CreateWholesalers:0x00000006bfc6a0>
C:/PW/Sites/grota/db/migrate/20170209014957_create_wholesalers.rb:7:in `block in change'
C:/PW/Sites/grota/db/migrate/20170209014957_create_wholesalers.rb:3:in `change'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
NameError: undefined local variable or method `limit' for # <CreateWholesalers:0x00000006bfc6a0>
C:/PW/Sites/grota/db/migrate/20170209014957_create_wholesalers.rb:7:in `block in change'
C:/PW/Sites/grota/db/migrate/20170209014957_create_wholesalers.rb:3:in `change'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
这是我的迁移代码:
class CreateWholesalers < ActiveRecord::Migration[5.0]
def change
create_table :wholesalers do |t|
t.string "brand_name", :limit => 25
t.string "username", :limit => 25
t.string "password_digest"
t.string "email", limit => 50
t.decimal "latitude"
t.decimal "longitude"
t.timestamps
end
end
end
提前致谢。
此行导致错误(缺少 :
):
t.string "email", :limit => 50
Cristiano Morais 应标记为正确答案。这是一个拼写错误。缺少 :