【发布时间】:2021-07-16 02:39:10
【问题描述】:
我正在尝试让通知在我的应用程序中工作。我从this GitHub repo 中找到了“引人注目的宝石”,并按照他所做的所有步骤进行操作。我的 gem 文件中有 gem,我做了 bundle install 和 update 以及 rails db:migrate 和一切。但是,当我尝试在 rails 控制台中运行它时
CommentNotification.with(post: @post).deliver(current_user)
我明白了
Traceback (most recent call last):
1: from (irb):1
NameError (uninitialized constant CommentNotification)
这是我在 app/notifications/comment_notificaiton.rb 下生成的 comment_notification.rb 类,当我运行 rails generate noticed:notification CommentNotification 时,正如他在视频中所做的那样,正如文档所建议的那样。
# To deliver this notification:
#
CommentNotification.with(post: @post).deliver_later(current_user)
CommentNotification.with(post: @post).deliver(current_user)
class CommentNotification < Noticed::Base
# Add your delivery methods
#
deliver_by :database
# deliver_by :email, mailer: "UserMailer"
# deliver_by :slack
# deliver_by :custom, class: "MyDeliveryMethod"
# Add required params
#
param :post
# Define helper methods to make rendering easier.
#
def message
t(".message")
end
#
def url
post_path(params[:post])
end
end
【问题讨论】:
-
reload! ?
-
它不起作用。我已经尝试重新加载!,并一起重新启动控制台,以及 VSCode 本身。
标签: ruby-on-rails ruby console