【发布时间】:2016-05-22 18:55:06
【问题描述】:
我正在尝试将我的应用程序的 rails 版本从 4.2.6 升级到 5,但我遇到了以下错误。
suramai@rails-tutorial:~/workspace/converse (rails5update) $ rails server -b $IP -p $PORT
=> Booting WEBrick
=> Rails 5.0.0.rc1 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
Exiting
/usr/local/rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.rc1/lib/active_support/core_ext/hash/keys.rb:79:in `block in assert_valid_keys': Unknown key: :order. Valid keys are: :class_name, :anonymous_class, :foreign_key, :validate, :autosave, :table_name, :before_add, :after_add, :before_remove, :after_remove, :extend, :primary_key, :dependent, :as, :through, :source, :source_type, :inverse_of, :counter_cache, :join_table, :foreign_type, :index_errors (ArgumentError)
from /usr/local/rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.rc1/lib/active_support/core_ext/hash/keys.rb:77:in `each_key'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.rc1/lib/active_support/core_ext/hash/keys.rb:77:in `assert_valid_keys'
from /usr/local/rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.rc1/lib/active_record/associations/builder/association.rb:78:in `validate_options'
改变范围
#default_scope -> { order: 'created_at DESC' }
scope :created_at, -> { order('created_at DESC') }
添加了 gem 文件
gem "responders"
创建
models/application_record.rb
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
确保所有模型都继承自这个新类,例如:
models/user.rb
class User < ApplicationRecord
[...]
end
有人遇到同样的问题吗?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-5