-1
這是第一次遇到這種錯誤的軌道,我真的不知道它在哪裏從這裏來的是功能實現:數錯誤的參數(2 3)
def self.send (sender,recivers,content)
recivers.each do |reciver|
@notification = Notification.new
@notification.sender= sender
@notification.user = reciver
@notification.body = content
@notification.save
end
end
這裏如何我打電話吧:
def after_create(announcment)
instructor_id = announcment.course.instructor_id
sender = User.find_by_id(instructor_id)
students = announcment.course.users
body = announcment.announcment
coures_name = announcment.course.name
Notification.send(sender,students,body)
UserMailer.notify_students_course(students,coures_name)
end
張貼錯誤日誌請輸入 – 7urkm3n
我發現了錯誤,它是在方法發送的名稱,但我不知道它爲什麼會創建一個錯誤是發送保留關鍵字? – mohamed
@mohamed這是一個Ruby對象類方法(因此每個類都繼承它)調用第一個參數命名的方法,併爲給予'send'的其餘參數調用參數。同樣在RoR中,它的[保留字](http://www.rubymagic.org/posts/ruby-and-rails-reserved-words) –