我刚刚尝试在控制台中查询事件,我收到以下错误消息:
`irb(main):003:0> Event
LoadError: Unable to autoload constant Event, expected /home/action/workspace/trendosaur/app/models/ahoy/event.rb to define it
from /home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:481:in load_missing_constant'
from /home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:180:in const_missing'
from (irb):3
from /home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/commands/console.rb:90:in start'
from /home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/commands/console.rb:9:in start'
from /home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:69:in console'
from /home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in run_command!'
from /home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/commands.rb:17:in <top (required)>'
from bin/rails:4:in require'
from bin/rails:4:in <main>'`
这是预期的行为吗?
这是我的模型:
module Ahoy
class Event < ActiveRecord::Base
self.table_name = "ahoy_events"
belongs_to :visit
belongs_to :user
end
end
和架构:
create_table "ahoy_events", id: false, force: true do |t|
t.uuid "id", null: false
t.uuid "visit_id"
t.integer "user_id"
t.string "name"
t.json "properties"
t.datetime "time"
end
add_index "ahoy_events", ["time"], name: "index_ahoy_events_on_time", using: :btree
add_index "ahoy_events", ["user_id"], name: "index_ahoy_events_on_user_id", using: :btree
add_index "ahoy_events", ["visit_id"], name: "index_ahoy_events_on_visit_id", using: :btree
谢谢