Railsアプリでいくつかの簡単な関連付けをセットアップしました:
resources :properties do
resources :units
end
ユニットを更新した後:
「localhost:3000/properties/2/units/3/edit」
適切な場所にリダイレクトされるようにしたい。
「更新」をクリックすると、次の場所にリダイレクトされます。
「localhost:3000/units/3」ですが、「localhost:3000/properties/2/units/3/」に移動する必要があります
私のユニットコントローラーには、次のものがあります。
if @unit.update_attributes(params[:unit])
format.html { redirect_to(property_units_path(@property, @unit), :notice => 'Unit was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @unit.errors, :status => :unprocessable_entity }
end
これは私の redirect_to 関数で適切に使用されていますか? 私はまだルートの仕組みに慣れようとしていますが、これでうまくいくと思いますか?
ありがとう!