So I have an if statement. If a customer exists return false. I was trying with an actual customer id but it was throwing an error, I replaced it with a 1. Still getting that error.
if Stripe::Customer.retrieve(1)
throws
undefined method `encoding' for 1:Fixnum
link to the api :
https://stripe.com/docs/api#retrieve_customer
All I had to do was
require "stripe"
... :|
Please check the https://stripe.com/docs/api/ruby#customers
There you can find that, in attributes it takes
id: string
So the code should be
#Stripe::Customer.retrieve({CUSTOMER_ID})
Stripe::Customer.retrieve(1.to_s)
Hope it will work.
Related
I am getting an error:
NoMethodError: undefined method `cards' for
V1::CardsControllerTest:0x00000007c17238
when I am making the following call in an integration test:
card = cards(:one)
even though I have defined the fixture 'Cards'.
Does anyone have an idea as to why this is happening?
I'm writing testing code for api created by grape in rails. There's an error: undefined method `response_body=' for #
does anyone knows the reason and how to fix this? I'll be very thankful for that.
It looks like your code is trying to set the value of response_body, which does not seem like what you want to do. The error is telling you that there is no setter for the attribute...
Error:
undefined method `author' for nil:NilClass
In my helper:
def last_updated(group)
g = group.last_updated_version
debugger
g.author.name
end
If I let my last_updated(group) function return group.last_updated_version, the view prints out my object as expected:
#<Assets::Version:0x0000000747af48>
And using the debugger at the point shown above, I can pull out the name
(rdb:1) g.author.name
"Administrator"
But returning group.last_updated_version.author.name results in the error.
Can anyone tell me why group.last_updated_version seems to return my object, but group.last_updated_version.author gives me the nil:NilClass error?
Sorry, silly problem. The helper last_updated() is used in a loop. My method last_updated_version returned nil for some of the group objects it was passed, but not the first. The debugger obviously stops on the first, so it worked in the debugger, but then broke on groups passed after that.
I am using the Cucumber unit test tool, and am trying to retrieve the value of a textarea, however I can't get it to work.
This is my code...
page.find(:xpath, "//div[#id='process']/table/tbody/tr/td/div/textarea").value
This is the error I'm getting...
Error: undefined method `value' for nil:NilClass (NoMethodError)
This URL listed below confirms that value is the correct method to retrieve the value:
http://www.w3schools.com/jsref/dom_obj_textarea.asp
Could someone please help me fix this problem.
The nil error indicates that you're not getting the textarea -- find is returning nil. Try a simpler xpath query, or referencing the textarea by name or id.
I am getting undefined method [] for true:TrueClass error while running the rake task in acts_as_recommendable plugin. The error points to the following line.
items = options[:on_class].find(:all).collect(&:id)
Can someone please tell what am i doing incorrectly.
options is probably defined as true. We can't really know why without more information.