0
我在控制这个动作:更新无效的属性重新呈现新的模板,而不是编辑
def update
@board = Board.find(params[:board_id])
@category = Category.find(params[:id])
if @category.update_attributes(category_params)
flash[:notice] = "You sucessfully changed category name."
redirect_to settings_board_path(@board)
else
render :edit
end
end
和解决这个测试案例:
context "with invalid attributes" do
let(:updated_category) { FactoryGirl.attributes_for(:category, name: "") }
it "re-renders :edit template" do
patch :create, board_id: board, id: category, category: updated_category
expect(response).to render_template :edit
end
end
我得到这个错误:
expecting <"edit"> but rendering with <["categories/new", "layouts/application"]>
任何想法为什么?
Blah,谢谢:) –