开发者

Ruby: Having trouble pulling data from this class

So here's the output of inspect on a class:

<Recurly::BillingInfo::CreditCard:0x1036a8a98 @prefix_options={}, @attributes={"month"=>1, "last_four"=>"1", "type"=>"开发者_如何学JAVAbogus", "year"=>2010}>

I'm trying to get the type attribute but seems that might be some sort of reserved word?

Here's the full rundown of what I'm trying to do

@charges = Recurly::BillingInfo.find('123')
@charges.credit_card.type

So, how can I get type from that?


Try this to see what methods are available to you:

@charges.credit_card.methods

Anyway I believe this should work for you:

@charges.credit_card.attributes['type']


In ActiveRecord "type" as an attribute is reserved for Single Table Inheritance associations I believe.

You may need to alias the name, or create a "card_type" attribute in your migration rather than a "type" attribute.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜