Ruby on Rails(3.2.2)、globalize3(0.2.0)、batch_translations(0.1.2)のruby-gemを使用しています。「保護属性の一括割り当てができない:translations_attributes」エラーを解決するにはどうすればよいですか?
class Admin::Article < ActiveRecord::Base
translates :title
# This is needed to make the batch_translations to work.
accepts_nested_attributes_for :translations
...
end
:私は私の
ROOT_RAILS/app/models/admin/article.rb
ファイルで
...
gem 'globalize3'
gem 'batch_translations'
:私は私のROOT_RAILS/Gemfile
ファイルで
ActiveModel::MassAssignmentSecurity::Error in Admin::ArticlesController#update
Can't mass-assign protected attributes: translations_attributes
:私はbatch_translationsルビーの宝石を使用したときに発生する次のような問題を解決したいと思います
私のROOT_RAILS/app/views/admin/articles/_form.html.erb
ファイルに私は持っています:
class Admin::ArticlesController < ApplicationController
def update
@admin_article = Article.find(params[:id])
respond_to do |format|
if @admin_article.update_attributes(params[:article])
format.html { redirect_to admin_article_path(@admin_erticle), notice: 'Article was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @admin_article.errors, status: :unprocessable_entity }
end
end
end
...
end
が、私はそのフォームを送信するとき、私は上記のエラーを取得:私のROOT_RAILS/app/controllers/admin/articles_controller.html.erb
ファイルで
は私が持っています。上記のエラーを解決するにはどうすればよいですか?
class Admin::Article < ActiveRecord::Base
translates :title
attr_accessible :translations_attributes
accepts_nested_attributes_for :translations
...
end
...しかし、それは確かである:translations_attributes
がアクセスできる:
UPDATE
私はROOT_RAILS/app/models/admin/article.rb
ファイルに次のコードを使用して、解決策を見つけましたか?