gpt4 book ai didi

ruby-on-rails - Rails "noticed gem"说未初始化的常量

转载 作者:行者123 更新时间:2023-12-05 06:01:25 25 4
gpt4 key购买 nike

我正在尝试让通知在我的应用程序中工作。我从 this GitHub repo 中找到了“引人注目的 gem ”并遵循他所做的所有步骤。我的 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)

这是我的 comment_notification.rb 类,当我运行 rails generate notification:notification CommentNotification 时,它会在 app/notifications/comment_notificaiton.rb 下生成,正如他在视频中所做的那样,正如文档所建议的那样.

# 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

最佳答案

您必须重新启动您的 spring 服务器。

使用bin/spring stop 命令,spring 服务器将停止。然后服务器将使用 rails serverrails s 启动。

关于ruby-on-rails - Rails "noticed gem"说未初始化的常量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67203675/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com