我使用Rails 3.2.14,inherited_resource和strong_parameter gem.I只是跟着Strong Parameters in Rails 3.2.8步驟,但我收到錯誤,如下面,強大的參數不能大規模指派保護屬性
Can't mass-assign protected attributes:content, title, nature_bien_id, nature_transaction_id, nbr_chambres, nbr_pieces, section_id, city, zip, surface_habitable, surface_terrain
我的控制器代碼就是這樣
def create
@mandat = current_user.mandats.new(mandats_params)
end
private
def annonce_params
params.require(:annonce).permit(:created_at, :description, :image, :dpe, :nature_bien_id, :nature_transaction_id,:nbr_chambres, :nbr_pieces, :prix_net_acquereur, :section_id, :surface_habitable,:surface_terrain, :titre, :annonce_images_attributes, :user_id, :ville, :zip, :reference,:available_time, :is_valid, :close, :reasonclosing, :annonce_support_ids, :equipement_ids)
end
感謝提前
是的,我給,但仍然會發生錯誤 – Balachandran
你重新啓動你的服務器? –