【发布时间】:2015-06-12 13:07:29
【问题描述】:
Ruby on Rails 初学者在这里。
在 localhost:3000 中出现此错误
ActiveRecord::PendingMigrationError 迁移待定。要解决此问题,请运行:bin/rake db:migrate RAILS_ENV=development
我在终端运行了 rake db:migrate 并得到了这个:
$ rake db:migrate
rake aborted!
SyntaxError: /Users/EuphoriaComplex/src/bookmarks/db/migrate/20150407050503_add_user_to_bookmark.rb:5: syntax error, unexpected tIDENTIFIER, expecting keyword_end
add has_many :bookmarks to app/models/user.rb
^
/Users/EuphoriaComplex/src/bookmarks/db/migrate/20150407050503_add_user_to_bookmark.rb:7: syntax error, unexpected tIDENTIFIER, expecting keyword_end
add belongs_to :user to app/model/user.rb
^
这是我在 Sublime 中的书签/db/migrate 中的代码:
class AddUserToBookmark < ActiveRecord::Migration
def change
add_column :bookmarks, :user_id, :integer
add has_many :bookmarks to app/models/user.rb
add belongs_to :user to app/model/user.rb
end
end
我正在关注本教程:http://12devs.co.uk/articles/writing-a-web-application-with-ruby-on-rails/ 我只做了“需要身份验证来管理你的书签”
“用户有很多书签”是有问题的部分。
【问题讨论】:
-
教程底部的注释指出
add belongs_to :user应该指向app/model/bookmark.rb
标签: ruby-on-rails ruby ruby-on-rails-3 terminal syntax-error