Hello, It's is the form of /cards/:id
I tried <li><%= link_to '<i class="fa fa-money"></i> Card'.html_safe, cart_path(cart) %> </li> <li><%= link_to '<i class="fa fa-money"></i> Card'.html_safe, cart_path(card) %> </li> but on both I see this message : undefined local variable or method `cart' undefined local variable or method `card' Roelof Op maandag 8 december 2014 14:23:33 UTC+1 schreef Vivek Sampara: > What is the url you're using to show this on a separate page ? > > if its in the pattern of "/cards/:id/something" then you dont have to > provide the card path as rails picks up @card object to build the path or > you'll have to pass the card variable inside the path method. > > eg > > <% @cards.each do |card| %> > <li><%= link_to '<i class="fa fa-money"></i> Card'.html_safe, > cart_path(card) %> </li> > <% end %> > > This way, rails would know "which" exact card this link should take them > to. > > > On Mon, Dec 8, 2014 at 6:48 PM, Roelof Wobben <[email protected] > <javascript:>> wrote: > >> Hello, >> >> I follow the Agile Web development book. >> >> Now as a extra challenge I try to make the card visible on a seperate >> page. >> >> So I made this link : >> >> <li><%= link_to '<i class="fa fa-money"></i> Card'.html_safe, cart_path >> %> </li> >> >> But now I see the above error message. >> When I do card_path (:id) I see a message that there is no card with the >> id of id. >> >> Roelof >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/rubyonrails-talk/9442f58f-58b5-475e-823d-c797431c41c3%40googlegroups.com >> >> <https://groups.google.com/d/msgid/rubyonrails-talk/9442f58f-58b5-475e-823d-c797431c41c3%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/46cea06c-0a2c-41e2-88c5-b3516c76c504%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

