create メソッドといくつかの検証を備えたかなり標準的なコントローラーがあります。
def create
@type = Type.new(params[:type])
respond_to do |format|
if @type.save
format.html { redirect_to types_path, notice: 'Type was successfully created.' }
format.json { render json: @type, status: :created, location: @type }
else
format.html { render action: "new" }
format.json { render json: @type.errors, status: :unprocessable_entity }
end
end
end
問題は、検証が失敗したときに、そこにないMissing template ontology/types/create
かのようにエラーが発生render action: "new"
することです。それを a に置き換えると、redirect_to
期待どおりに機能しますが、フォームエラーを渡すことができないようです。
new の元の呼び出しから @type インスタンス (@type.errors を含む) が存在することを知っており、render 呼び出しの直前にそれをスローすると、これが確認されます。
更新時に検証が失敗した場合も同じことが起こっています。レンダリング呼び出しが無視されているようです!
注: 私のルーティング構造は少し型破りですが、これが関連している理由がわかりません。