且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQLite3::SQLException: 没有这样的表: 消息: SELECT "messages".* FROM "messages";

更新时间:2023-12-01 13:59:28

@messages = Message.all

告诉 Rails 应用程序查询数据库以获取消息表中的每条消息.所以如果你想使用一个以这种方式使用 Rails 应用程序,那么是的,您必须拥有某种 messages 表.您说您不打算存储消息,因此 index 操作应该转到空白聊天屏幕.所以只要去掉@messages = Message.all.如果你想要一个滚动的聊天消息列表,我想你可以将每一行写入一个数组并让索引页面显示出来.只需在聊天会话开始时将该数组设置为空白即可.

Tells the Rails app to query the db for every message in the message table. So if you want to use a Rails app in that way, then yes you would have to have some sort of a messages table. You said you are not looking to store the messages so the index action should go to a blank chat screen. So just get rid of @messages = Message.all. If you wanted to have a scrolling list of chat messages I guess you could just write each line to an array and have the index page show that. Just set that array to be blank at the beginning of a chat session.