ruby on rails 3 - Passing parameters with links -
routes.rb
resources :carts resources :cart_items end
rake routes:
cart_cart_items post /carts/:cart_id/cart_items(.:format) cart_items#create
when click on link, should create new item in cart_items:
link_to 'add cart', '#'
i need link. how pass :cart_id through link.i'm newbie rails. in advance.
assuming have @cart
, doing link_to 'add cart', cart_path(@cart)
suffice.
Comments
Post a Comment