gpt4 book ai didi

ruby-on-rails - Ruby on Rails错误 rake db :migrate

转载 作者:行者123 更新时间:2023-12-03 08:05:20 24 4
gpt4 key购买 nike

每当我运行rake db:migrate RAILS_ENV=development时,它就会返回语法错误

rake aborted!
SyntaxError: /Users/IsaiahxD/.rvm/gems/ruby- 2.2.1@rails3tutorial/rails_projects/first_app/db/migrate/20150825050353_create_u sers.rb:21: syntax error, unexpected keyword_end, expecting end-of-input
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activesupport- 4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:773:in `load_migration'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:769:in `migration'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:764:in `disable_ddl_transaction'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:1047:in `use_transaction?'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:1039:in `ddl_transaction'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:993:in `execute_migration_in_transaction'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:955:in `block in migrate'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:951:in `each'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:951:in `migrate'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:819:in `up'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:797:in `migrate'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/Users/IsaiahxD/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'

任务:TOP => db:migrate
(通过使用--trace运行任务来查看完整的跟踪)

我检查了一切,所有返回的是
"20150825050353_create_users.rb:21: syntax error, unexpected keyword_end,  expecting end-of-input"


class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.column "first_name", :string, :limit => 25
t.string "last_name", :limit => 50
t.string "email", :default => "", :null => false
t.string "password", :limit => 40
t.datetime "created_at"
t.datetime "updated_at"
t.timestamps null: false
end
end

def down
drop_table :users
end
end

最佳答案

更改:

t.timestamps null: false

至:
t.timestamps :null => false

关于ruby-on-rails - Ruby on Rails错误 rake db :migrate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32304250/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com