我刚刚更新到Mailboxer 0.12.4并遵循Github自述文件中的说明。我有两个控制器,用于创业板从Mailboxer 0.11.0升级到0.12.4的问题
通知工作
class NotificationsController < ApplicationController
before_action :signed_in_user, only: [:create]
def new
@user = User.find(:user)
@message = current_user.messages.new
end
def create
@recepient = User.find(params[:notification][:id])
current_user.send_message(@recepient, params[:notification][:body],params[:notification][:subject])
flash[:success] = "Message has been sent!"
redirect_to user_path @recepient
end
end
对话
class ConversationsController < ApplicationController
before_action :signed_in_user
def index
@conversations = current_user.mailbox.conversations.paginate(page: params[:page],:per_page => 5)
end
def show
@conversation = current_user.mailbox.conversations.find_by(:id => params[:id])
@receipts = @conversation.receipts_for(current_user).reverse!
end
end
我的用户模型act_as_messagable。更新后,我的用户控制器中的这个方法抛出一个错误。
未初始化的常量UsersController ::通知
的代码高亮显示是
def show
@user = User.find(params[:id])
@message = Notification.new << this line
....
end
我试图创建在控制台中通知的对象,我也得到了同样的错误。我读过更新已经改变了命名空间,但我不知道如何改变我的代码来解决这个问题。
This is the closest I have found to a solution but the guy doesn't say how he fixed it