シンプルな Ajax アップデートを使用して、Rails にシンプルなチャット ルーム機能を実装しました。現在、すべてのチャット ルームで、メッセージは特定のユーザーに属しています。ユーザーのリスト (ユーザーの存在など) を表示したいと考えています。方法を提案してください。Jabber、XMPPなどは使用していません。
チャットルームのモデルは次のとおりです。
class ChatRoom < ActiveRecord::Base
validates_presence_of :title
has_many :messages,:foreign_key=> "chat_room_id"
has_many :stories,:foreign_key=>"chat_room_id"
has_many :topics,:foreign_key=>"chat_room_id"
end
メッセージは、すべてのユーザーが送信したチャットです。
メッセージ モデルは次のとおりです。
class Message < ActiveRecord::Base
belongs_to :user
end
ユーザーモデルは次のとおりです。
class User < ActiveRecord::Base
acts_as_authentic :crypto_provider => Authlogic::CryptoProviders::BCrypt
validates_presence_of :nick
validates_uniqueness_of :nick
has_many :questions
end
方法を提案してください