Ruby on Rails Saturday, September 1, 2012

On 1 September 2012 06:43, Khan <emailtosameenakhan@gmail.com> wrote:
> Hi all i am following this like for basic paypal
> http://railscasts.com/episodes/141-paypal-basics
> and i got this error
>
>
> View:
>
> <%= link_to "Checkout", @cart.paypal_url() %>
>
> undefined method `paypal_url' for nil:NilClass

That means that @cart is nil. The error messages in rails are not
always perfectly clear but usually careful consideration of the
message will yield clues as to the problem.

> despite i have this code in my model called Card
>
> Cart Model:
>
> class Cart < ActiveRecord::Base
>

[snip]

> end
>
>
> end
>
> it is unable to identify it
>
> what is the problem

As I said at the top the problem is that @cart is nil, it is probably
not a problem in the model itself, but in the controller. Have a look
at the Rails Guide on debugging which will provide techniques you can
use to debug the code and work out why it is nil.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment