服务抛出"undefined method"错误



我可能错过了一些明显的东西,但我无法弄清楚我的问题在哪里。我有一个名为GoodMorning的服务(app/services/good_morning.rb(

class GoodMorning
def self.dawn(user)
if user.goal_days.where("day = ?", Date.today).count == 0
user.goals.each do |goal|
if goal[time.strftime("%A")] == true
GoalDay.create(goal_id: goal.id, body: goal.body, target: goal.target, actual: 0, day: Date.today)
end
end
session[:sun] = true
end
end
end

然后在一个名为 Clearing (app/controllers/clearing_controller.rb( 的控制器中,我称之为:

def index
@user = current_user
@goals_today = GoalDay.where("user_id = ? AND day = ?", @user.id, Date.today)
if session[:sun] == true
if @goals_today.count == 0
session[:sun] = false
end
else
GoodMorning(@user).dawn
end
end

我收到以下错误:

# 的未定义方法 'GoodMorning'

感谢您帮助看到我缺少什么!我重新启动了服务器等。

试试...

GoodMorning.dawn(@user)

相关内容

最新更新