我收到有關強參數的錯誤消息。我認爲這只是導軌4不再使用屬性。我toy.rb的代碼是:Ruby中的強參數
class Toy < ActiveRecord::Base
attr_accessible :name, :price, :vendor
validates :name, :presence => true
validates :price, :presence => true
validates :price, :numericality => true
validates :vendor, :presence => true
end
我該如何將此更改爲強參數?
編輯:我使用了不同的RB我改成了員工,這是我所:
class Employee < ActiveRecord::Base
params.require(:employee).permit(:first, :last, :salary, :salary, :ssn)
validates :first, :presence => true
validates :last, :presence => true
validates :salary, :presence => true
validates :salary, :numericality => true
validates :ssn, :presence => true
末
它仍然告訴我,「ndefined局部變量或方法`PARAMS'爲# 「
您是否試過使用谷歌搜索「導軌4強參數」? –