新手最近在看 agile web development with rails 电子版,有几行代码看不明白,求教:
<%= button_to 'Add to Cart', line_items_path(product_id: product) %>
看不懂为什么这个 line_items_path(product_id: product)
调用了 line_items controller 的 create 方法?哪里规定的?
Download rails32/depot_g/test/functional/line_items_controller_test.rb
test "should create line_item" do
assert_difference('LineItem.count') do
➤ post :create, product_id: products(:ruby).id
end
➤ assert_redirected_to cart_path(assigns(:line_item).cart)
end
这里 (:ruby) 什么用途? 谢谢啊