迁移文件中出现奇怪的语法错误

时间:2014-12-08 11:17:29

标签: ruby-on-rails ruby

我检索到这个奇怪的错误,我无法解释:

→ rake db:migrate:redo
rake aborted!
SyntaxError: .../db/migrate/20141208102936_transition_reviews_to_be_polymorphic.rb:20: syntax error, unexpected end-of-input, expecting keyword_end

这是来源:

class TransitionReviewsToBePolymorphic < ActiveRecord::Migration

#   class Review < ActiveRecord::Base
#   end

  def change
    # Review.reset_column_information

    reversible do |dir|
#       dir.up do
#     #     Review.find_each do |review|
#     #       review.reviewable_id = review.schedule_id
#     #       review.reviewable_type = 'Schedule'
#     #       review.save
#     #     end
#       end
    end
  end

end

1 个答案:

答案 0 :(得分:0)

您的文件包含多个non-breaking spaces(显示为下划线):

class TransitionReviewsToBePolymorphic < ActiveRecord::Migration

#   class Review < ActiveRecord::Base
# __end

  def change
    # Review.reset_column_information

    reversible do |dir|
# ______dir.up do
#     #     Review.find_each do |review|
#     #       review.reviewable_id = review.schedule_id
#     #       review.reviewable_type = 'Schedule'
#     #       review.save
#     # ____end
#       end
____end
  end

end