2016-04-11 48 views
-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 
+0

張貼錯誤日誌請輸入 – 7urkm3n

+1

我發現了錯誤,它是在方法發送的名稱,但我不知道它爲什麼會創建一個錯誤是發送保留關鍵字? – mohamed

+0

@mohamed這是一個Ruby對象類方法(因此每個類都繼承它)調用第一個參數命名的方法,併爲給予'send'的其餘參數調用參數。同樣在RoR中,它的[保留字](http://www.rubymagic.org/posts/ruby-and-rails-reserved-words) –

回答

2

sendObject類(所以每一個類繼承它)調用與第一個參數命名的方法和參數的給send參數的其餘一個Ruby方法。另外在RoR它的一個reserverd word

最好不要壓倒它,因爲它會變得混亂。

相關問題