我試圖推動一些代碼到heroku。Rails 4 - Heroku日誌 - 如何使錯誤消息有意義
我從heroku日誌中收到此錯誤消息。我無法理解它。
,只要我能破譯,它的東西與我的用戶和角色模型,它們分別是:
用戶
rolify
attr_accessor :current_role
has_and_belongs_to_many :roles, join_table: "users_roles"
角色
class Role < ActiveRecord::Base
has_and_belongs_to_many :users, join_table: "users_roles"
belongs_to :resource, :polymorphic => true
validates :resource_type,
:inclusion => { :in => Rolify.resource_types },
:allow_nil => true
scopify
end
User_Roles連接表:
create_table "users_roles", id: false, force: :cascade do |t|
t.integer "user_id"
t.integer "role_id"
end
add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id", using: :btree
任何人都可以理解這個錯誤消息的含義嗎?
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.4/lib/active_record/associations.rb:1694: warning: already initialized constant User::HABTM_Roles
2016-04-22T03:11:57.250562+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.4/lib/active_record/associations.rb:1694: warning: previous definition of HABTM_Roles was here
2016-04-22T03:11:58.690994+00:00 app[web.1]: [3] ! Unable to load application: ArgumentError: Unknown key: :polymorphic. 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
2016-04-22T03:11:58.691033+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.4/lib/active_support/core_ext/hash/keys.rb:75:in `block in assert_valid_keys': Unknown key: :polymorphic. 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 (ArgumentError)
我剛剛發現的資源下面介紹如何「rolify」結合用戶模型HABTM關係,所以它並不需要被作爲一個協會單獨列出,但我仍然得到這個錯誤:
Preloading application
2016-04-22T04:09:58.023038+00:00 app[web.1]: [3] ! Unable to load application: ArgumentError: Unknown key: :polymorphic. 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
2016-04-22T04:09:58.023056+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.4/lib/active_support/core_ext/hash/keys.rb:75:in `block in assert_valid_keys': Unknown key: :polymorphic. 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 (ArgumentError)
你可以嘗試將連接表重命名爲符號嗎?所以:user_roles而不是「user_roles」 –
嗨,我只是試着將它從:join_table =:user_roles更改爲上面的方式。這對錯誤信息沒有任何影響。我試圖破譯錯誤意味着什麼?你能理解這個消息嗎? – Mel