レコメンデーション用のシンプルなフォームがあります。REcommendations has_many アセット。
私のコントローラーでは、簡単なことをしています:
6.times {@recommendation.assets.build}
この問題は、推奨事項を保存しようとしたときに検証エラーが発生したときに発生します。私の作成アクション:
def create
@recommendation = Recommendation.new(params[:recommendation])
@recommendation.user_id = current_user.id
respond_to do |format|
if @recommendation.save
format.html { redirect_to thankyou_path, notice: 'Recommendation was successfully created.' }
else
6.times {@recommendation.assets.build} if @recommendation.assets.blank?
render action: "new"
end
end
end
このページを実行して送信すると (検証エラーあり)、次のログ出力と http 406 エラーが発生します
Started POST "/categories/1/awards/9/recommendations" for 127.0.0.1 at 2013-01-07 11:50:13 -0800
Processing by RecommendationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"8PVfFZGa72+3KU/km2weZhNy0rxRfp0Qd+CkHdBoQM8=", "recommendation"=>{"nominee"=>"", "title"=>"", "department"=>"", "award_id"=>"9", "summary"=>"", "accomplishments"=>"", "caption"=>"", "url"=>"", "supervisor"=>"You ARE NOT the nominee’s direct manager / supervisor", "approvals_attributes"=>{"0"=>{"email"=>""}}}, "commit"=>"Save/Submit", "category_id"=>"1", "award_id"=>"9"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2 LIMIT 1
(0.2ms) BEGIN
(0.1ms) ROLLBACK
Rendered shared/_recommend_timeline.html.erb (1.2ms)
Award Load (20.1ms) SELECT "awards".* FROM "awards" WHERE "awards"."id" = 9 LIMIT 1
Rendered recommendations/_form.html.erb (66.7ms)
Rendered recommendations/new.html.erb within layouts/application (69.8ms)
(0.5ms) SELECT COUNT(*) FROM "recommendations" WHERE "recommendations"."user_id" = 2
(0.6ms) SELECT COUNT(*) FROM "approvals" WHERE "approvals"."email" = 'tj@ravennainteractive.com' AND "approvals"."approved" IS NULL
Completed 406 Not Acceptable in 556ms (Views: 188.6ms | ActiveRecord: 31.5ms)
似ているように見えるスタックに関する複数の質問を見てきましたが、