我有一个工人:
module A
class B
@queue = :a_b
def self.perform(*args)
...............
city = City.where(:country_id => 1).first
city.update_attributes(name: "Delhi", continent: "Asia") //mass-assignment here
...............
end
end
end我在city.rb中没有attr_accessible :name, :continent。如何从工作人员中删除此成批分配?
发布于 2015-06-18 07:57:30
查看链接https://github.com/rails/strong_parameters,了解如何在控制器外使用强参数。
raw_parameters = { :email => "john@example.com", :name => "John", :admin => true }
parameters = ActionController::Parameters.new(raw_parameters)
user = User.create(parameters.permit(:name, :email))https://stackoverflow.com/questions/30904311
复制相似问题