I've tried to follow the ActionCable tutorial - Site point and I convert this tutorial to using MongoDB. But I have the problems with devise
NoMethodError in Devise::RegistrationsController#create
undefined method `after_create_commit' for Message:Class Did you mean? after_create
I don't have any ideas about this problems. Please help me, thank you so much.
message.rb
class Message
include Mongoid::Document
field :body, type: String
belongs_to :user
belongs_to :chat_room
validates :body, presence: true, length: {minimum: 2, maximum: 1000}
after_create_commit { MessageBroadcastJob.perform_later(self) }
def timestamp
created_at.strftime('%H:%M:%S %d %B %Y')
end
end
Got turbo-broadcasting from models work with mongoid. The steps were:
Hope this helps to someone.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.