Ruby on rails Rails 4.0-NameError uninitialized contant-与非常规外键有很多关系

Ruby on rails Rails 4.0-NameError uninitialized contant-与非常规外键有很多关系,ruby-on-rails,Ruby On Rails,我尝试在下表中存储用户之间的消息。我已尽我所能设置了关系,但我在消息中遇到了名称错误35;索引未初始化常量成员::消息 消息表的数据库架构 create_table "messages", force: true do |t| t.datetime "created_at" t.datetime "updated_at" t.text "message", null: false t.boolean "read", null: false t.in

我尝试在下表中存储用户之间的消息。我已尽我所能设置了关系,但我在消息中遇到了
名称错误35;索引
未初始化常量成员::消息

消息表的数据库架构

create_table "messages", force: true do |t|
  t.datetime "created_at"
  t.datetime "updated_at"
  t.text     "message",    null: false
  t.boolean  "read",       null: false
  t.integer  "from_id",    null: false
  t.integer  "to_id",      null: false
end
成员模型

class Member < ActiveRecord::Base
  has_many :received_messages, :class_name => :messages, :foreign_key => "to_id"
end
类成员:messages,:foreign\u key=>“到\u id”
结束
消息模型

class Message < ActiveRecord::Base
  belongs_to :member
end
class消息
带辅助方法的应用程序控制器

class ApplicationController < ActionController::Base

  helper_method :unread_messages

  def unread_messages
    @unread_messages ||= current_user.received_messages.where(:unread => true) unless current_user.received_messages.nil?
  end
end
class ApplicationControllertrue),除非当前_用户。已接收_消息。nil?
结束
结束
我在aplication.html.erb布局模板中的此语句中收到错误


是什么导致了这个问题。这是一个非常普遍的错误,通常意味着我忘记设置关联,但是这个关联是不同的,我以前没有做过一个超出默认命名约定的关联。。。想法?

:类名
键应该是“Message”