我终于有了Rails 5和Ruby 2.5.8的完美搭配。
迁移是最新的,并且运行良好。
我正在使用Elasticsearch进行搜索,并使用Memcache进行缓存-都可以(或者至少我认为它们可以)。
我添加了ApplicationRecord类以从ActiveRecord :: Base继承,并更新了我所有的类以从ApplicationRecord继承。
我已经禁用了attr_accessible gem,但是我仍然必须为strongparameters编写代码。
我的Rails服务器启动,但是当我访问我的站点时,我得到以下信息:
“在自动加载常量Sub时检测到循环依赖”
Sub(类似于reddit子)是一个非常简单的类。
有人知道我在做什么错吗?
顺便说一句,是的,我已经搜索过Google,SO等,但似乎找不到解决方法。
任何帮助将不胜感激。
好这是Sub类中最有趣的部分:
require 'elasticsearch/model'
class Sub < ApplicationRecord
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
has_many :comments
attr_accessible :name, :is_private, :is_banned, :is_default, :log_line, :rules, :posted, :nsfw, :is_read_only, :metadata
validates_presence_of :name, :message => "* required"
validates_length_of :name, :minimum => 4, :message => "minimum of 4 characters"
validates :name, length: {maximum: 20}
validates_format_of :name, :with => /\A[a-zA-Z0-9_]+$\Z/, :message => "letters, numbers and underscores only"
对于elasticsearch,我在课程结束时有这个提示:
def self.search(q)
__elasticsearch__.search(
{
query: {
multi_match: {
query: q, fields: ["name^10", "metadata.log_line^5", 'metadata.sidebar_text^1']
}
}
}
)`enter code here`
end
所以它的加载位置在comment.rb中:
class Comment < ApplicationRecord
belongs_to :sub
belongs_to :user
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
validates :root_comment_id, presence: true
validates :sub_id, presence: true
实际调用在comment.rb模型中:
这是类的定义:
class Comment < ActiveRecord
belongs_to :sub
belongs_to :user
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
validates :root_comment_id, presence: true
validates :sub_id, presence: true
这就是它的称呼方式:
sub = Sub.find_by_id(sub_id)
这是错误的追溯:
Circular dependency detected while autoloading constant Sub
rendering 404 in h_controller
Rendering errors/oops.html.erb within layouts/application
Rendered errors/oops.html.erb within layouts/application (4.3ms)
Rendered shared/_sidebar.html.erb (31.4ms)
----- Start BACKTRACE -----
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:509:in `load_missing_constant'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:203:in `const_missing'
/home/colin/railsworkspace/headcycle/app/admin/sub.rb:1:in `<top (required)>'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:477:in `load'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:477:in `block in load_file'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:662:in `new_constants_in'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:476:in `load_file'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:375:in `block in require_or_load'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:37:in `block in load_interlock'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/concurrency/share_lock.rb:117:in `exclusive'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies/interlock.rb:11:in `loading'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:37:in `load_interlock'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:358:in `require_or_load'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:511:in `load_missing_constant'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:203:in `const_missing'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:543:in `load_missing_constant'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:203:in `const_missing'
/home/colin/railsworkspace/headcycle/app/controllers/h_controller.rb:24:in `set_default_sub_info'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:382:in `block in make_lambda'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:169:in `block (2 levels) in halting'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/abstract_controller/callbacks.rb:12:in `block (2 levels) in <module:Callbacks>'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:170:in `block in halting'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:454:in `block in call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:454:in `each'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:454:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:448:in `block (2 levels) in around'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:271:in `block in halting_and_conditional'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:447:in `block in around'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:455:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:101:in `__run_callbacks__'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:90:in `run_callbacks'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/abstract_controller/callbacks.rb:19:in `process_action'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_controller/metal/rescue.rb:20:in `process_action'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/notifications.rb:164:in `block in instrument'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/notifications.rb:164:in `instrument'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activerecord-5.0.0/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/abstract_controller/base.rb:126:in `process'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionview-5.0.0/lib/action_view/rendering.rb:30:in `process'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_controller/metal.rb:190:in `dispatch'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_controller/metal.rb:262:in `dispatch'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/routing/route_set.rb:32:in `serve'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/journey/router.rb:39:in `block in serve'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/journey/router.rb:26:in `each'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/journey/router.rb:26:in `serve'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/routing/route_set.rb:725:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/warden-1.2.9/lib/warden/manager.rb:36:in `block in call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/warden-1.2.9/lib/warden/manager.rb:34:in `catch'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/warden-1.2.9/lib/warden/manager.rb:34:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/etag.rb:27:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/conditional_get.rb:27:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/head.rb:12:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:266:in `context'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:260:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/cookies.rb:613:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activerecord-5.0.0/lib/active_record/migration.rb:552:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:90:in `run_callbacks'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/callbacks.rb:36:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/executor.rb:12:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:36:in `call_app'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:24:in `block in call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:70:in `block in tagged'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:26:in `tagged'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:70:in `tagged'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:24:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/request_id.rb:24:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/runtime.rb:22:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/executor.rb:12:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/static.rb:136:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/railties-5.0.0/lib/rails/engine.rb:522:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/configuration.rb:227:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/server.rb:706:in `handle_request'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/server.rb:476:in `process_client'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/server.rb:334:in `block in run'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/thread_pool.rb:135:in `block in spawn_thread'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:509:in `load_missing_constant'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:203:in `const_missing'
/home/colin/railsworkspace/headcycle/app/admin/sub.rb:1:in `<top (required)>'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:477:in `load'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:477:in `block in load_file'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:662:in `new_constants_in'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:476:in `load_file'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:375:in `block in require_or_load'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:37:in `block in load_interlock'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/concurrency/share_lock.rb:117:in `exclusive'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies/interlock.rb:11:in `loading'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:37:in `load_interlock'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:358:in `require_or_load'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:511:in `load_missing_constant'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:203:in `const_missing'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:543:in `load_missing_constant'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:203:in `const_missing'
/home/colin/railsworkspace/headcycle/app/controllers/h_controller.rb:24:in `set_default_sub_info'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:382:in `block in make_lambda'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:169:in `block (2 levels) in halting'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/abstract_controller/callbacks.rb:12:in `block (2 levels) in <module:Callbacks>'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:170:in `block in halting'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:454:in `block in call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:454:in `each'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:454:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:448:in `block (2 levels) in around'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:271:in `block in halting_and_conditional'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:447:in `block in around'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:455:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:101:in `__run_callbacks__'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:90:in `run_callbacks'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/abstract_controller/callbacks.rb:19:in `process_action'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_controller/metal/rescue.rb:20:in `process_action'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/notifications.rb:164:in `block in instrument'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/notifications.rb:164:in `instrument'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activerecord-5.0.0/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/abstract_controller/base.rb:126:in `process'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionview-5.0.0/lib/action_view/rendering.rb:30:in `process'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_controller/metal.rb:190:in `dispatch'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_controller/metal.rb:262:in `dispatch'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/routing/route_set.rb:32:in `serve'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/journey/router.rb:39:in `block in serve'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/journey/router.rb:26:in `each'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/journey/router.rb:26:in `serve'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/routing/route_set.rb:725:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/warden-1.2.9/lib/warden/manager.rb:36:in `block in call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/warden-1.2.9/lib/warden/manager.rb:34:in `catch'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/warden-1.2.9/lib/warden/manager.rb:34:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/etag.rb:27:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/conditional_get.rb:27:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/head.rb:12:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:266:in `context'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:260:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/cookies.rb:613:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activerecord-5.0.0/lib/active_record/migration.rb:552:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:90:in `run_callbacks'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/callbacks.rb:36:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/executor.rb:12:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:36:in `call_app'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:24:in `block in call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:70:in `block in tagged'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:26:in `tagged'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:70:in `tagged'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:24:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/request_id.rb:24:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/runtime.rb:22:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/activesupport-5.0.0/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/executor.rb:12:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/static.rb:136:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/railties-5.0.0/lib/rails/engine.rb:522:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/configuration.rb:227:in `call'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/server.rb:706:in `handle_request'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/server.rb:476:in `process_client'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/server.rb:334:in `block in run'
/home/colin/.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/puma-3.12.6/lib/puma/thread_pool.rb:135:in `block in spawn_thread'
----- END BACKTRACE -----
答案 0 :(得分:0)
您将comment.rb
的内容发布了两次。一个是从ActiveRecord
继承而另一个是从ApplicationRecord
继承。
不确定您是否有2个comment.rb
文件,但应该只有一个,并且该文件应该继承自ApplicationRecord