2012-03-10 19 views

回答

1

在這個特定的情況下,save沒有任何參數。這就是裸體摔跤的情況。但是,正如你可能知道,在ActiveRecord模型調用save接受的選擇,因爲這種方法得到由ActiveRecord::Validations這裏覆蓋:

https://github.com/rails/rails/blob/v3.1.3/activerecord/lib/active_record/validations.rb#L47

# The validation process on save can be skipped by passing <tt>:validate => false</tt>. The regular Base#save method is 
# replaced with this when the validations module is mixed in, which it is by default. 
def save(options={}) 
    perform_validations(options) ? super : false 
end 
+0

所以它被稱爲[裸體圖示(HTTP://行尾.wordpress.com/2011/01/21 /的怪-紅寶石圖示/)。有趣。 – zahanm 2012-03-10 21:44:30

+0

@ZahanM好的,星號被認爲是Ruby中的「splat運算符」。我剛剛製作的「裸體」部分,所以我會毫不猶豫地認爲這是一個無處不在的名字。也就是說,它不太可能被誤認爲與Ruby有關的其他東西,所以我認爲它的使用是安全的。 :) – coreyward 2012-03-11 00:26:37