2014-09-19 60 views
1

使用不能大規模指派保護屬性在Activeadmin

軌4.0.2和 activeadmin 1.0

型號:

class Tag < ActiveRecord::Base 
translates :url, :alt_tag, :h1, :content, :name, :nav_content, :meta_desc, :meta_title 

has_many :tag_translations 
accepts_nested_attributes_for :tag_translations, allow_destroy: true 

end 

class class TagTranslation < ActiveRecord::Base 

belongs_to :tag 
    validates_uniqueness_of :locale, :scope => :tag_id 
end 

activeadmin

ActiveAdmin.register Tag do 



     def permitted_params 
      params.permit tag: [:name, :active_general, :active_general_breakfasts, :active_general_apartments, 
        :active_article, :country_id, :region_id, :active_country_houses, :active_country_appartments, 
        :active_country, :meta_desc, :meta_title, :active_house, :active_apartment, :tag_list, 
        :nav_content, :alt_tag, :h1, :content, :name, tag_translations_attributes: [:id, :tag_id, :locale, 
        :alt_tag, :h1, :content, :name, :nav_content, :meta_desc, :meta_title, :_destroy, :_create, :_update,:_update]] 
     end 

end 

我得到這個錯誤消息在日誌文件中。我在這裏做錯了什麼?

WARNING: Can't mass-assign protected attributes for Tag: country_id, region_id, active_house, active_apartment, active_general, active_general_apartments, active_general_breakfasts, active_article, name, h1, content, alt_tag, nav_content, url, meta_desc, meta_title 

WARNING: Can't mass-assign protected attributes for Tag::Translation: locale 

thanks..remco

回答

1
ActiveAdmin.register Tag do 

    permit_params :name, :active_general, :active_general_breakfasts, :active_general_apartments, 
       :active_article, :country_id, :region_id, :active_country_houses, :active_country_appartments, 
       :active_country, :meta_desc, :meta_title, :active_house, :active_apartment, :tag_list, 
       :nav_content, :alt_tag, :h1, :content, :name, tag_translations_attributes: [:id, :tag_id, :locale, 
       :alt_tag, :h1, :content, :name, :nav_content, :meta_desc, :meta_title, :_destroy, :_create, :_update,:_update] 

end 
+0

我試過......但我仍然得到同樣的錯誤 – Remco 2014-09-20 07:01:00

相關問題