Ruby on Rails Friday, August 31, 2012

Putting aside the fact that you didn't give enough information about to diagnose the problem, I'll only answer because it's obvious. 


The answer to your question lies in the origins of the @cart instance variable. It's not defined automagically;  you should define it in the controller, and you are most likely forgetting to do it.


On Sat, Sep 1, 2012 at 12:43 AM, 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
despite i have this code in my model called Card

Cart Model:

class Cart < ActiveRecord::Base





def paypal_url(return_url)
values = {
:business => '',
:cmd => '_cart',
:upload => 1,
:return => return_url,
:invoice => id
}
line_items.each_with_index do |item, index|
values.merge!({
"amount_#{index+1}" => 500,
"item_name_#{index+1}" => car,
"item_number_#{index+1}" => 5,
"quantity_#{index+1}" => 1
})
end
"https://www.sandbox.paypal.com/cgi-bin/webscr?" + values.to_query
end


end

it is unable to identify it

what is the problem


Cheers


--
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.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/ph2CGAAof2cJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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