Ruby on Rails 控制器动作是一个私有方法 [英] Ruby on Rails Controller action is a private method

查看:36
本文介绍了Ruby on Rails 控制器动作是一个私有方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要了

private method `new' called for Reminder:Class

应用程序跟踪是

app/controllers/reminders_controller.rb:27:in `new'

新动作如下

 def new
    @reminder = @current_user.reminders.build()
    @title = "New Reminder"
    respond_to  do |format|
      format.html # new.html.erb
      format.json { render json: @reminder }
    end
  end

提醒模型如下

class Reminder < ActiveRecord::Base
belongs_to :user
belongs_to :assignment
attr_accessible :datetime, :sent_at, :status, :send_time

STATUSES = ["Not Sent", "Sending", "Sent", "Canceled"]

validates_presence_of :sent_at, :status, :user_id, :assignment_id 

before_save :round_tine


def round_time
  self.send_time = Time.at(t.to_i/(15*60)*(15*60))
end
end

我不知道该方法将如何私有.提前感谢您的帮助!

I don't know how the method would be private. Thanks for the help in advance!

更新: 向模型添加了一个方法.错误仍然发生.

UPDATE: Added a method to the model. Error still occurs.

推荐答案

将邮件程序类名称设为 ReminderMailer 而不仅仅是 Reminder.这就是 rails 无法区分两个类的问题,它正在识别名称为 Reminder 的邮件程序类的新方法并显示错误.

put mailer class name as ReminderMailer not just Reminder. That's the problem rails is not able to distinguish between two classes and it is identifying the new method for mailer class which has name Reminder and showing the error.

这篇关于Ruby on Rails 控制器动作是一个私有方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆