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

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -