If you're on  "/cards/:id", then look at your cards_controller.rb  , you'd
see @card defined , hence you should use   <li><%= link_to '<i class="fa
fa-money"></i> Card'.html_safe, cart_path(@card) %> </li>

But why would you goto to the show page ( /cards/:id/ ) when you're already
on the page ? regarding the cart, You have to follow the same procedure.
define @cart in the controller/action and use it like this

<li><%= link_to '<i class="fa fa-money"></i> Card'.html_safe,
cart_path(@cart) %> </li>

If you can give more info on what you're trying to do (app structure) , We
can help you a bit better :)

PS: i haven't read the book

Cheers
Vivek


On Mon, Dec 8, 2014 at 7:00 PM, Roelof Wobben <[email protected]> wrote:

> 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]> 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].
>>> 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/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
> <https://groups.google.com/d/msgid/rubyonrails-talk/46cea06c-0a2c-41e2-88c5-b3516c76c504%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/CAFKVRj_SgMF7HEVX%3Duy1zYiFVSR87PuoowS_OhFm6Y_AFiVhpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to