# Activeresource issue - Rails 2.2

**URL:** <https://www.ruby-forum.com/t/activeresource-issue-rails-2-2/167606>\
**Category:** Rails\
**Created:** [May 10, 2009, 5:07am UTC](https://www.ruby-forum.com/t/activeresource-issue-rails-2-2/167606 "2009-05-10T05:07:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![erik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b5ac83/32.png) [@erik](https://www.ruby-forum.com/u/erik)\
**Post date:** [May 10, 2009, 5:07am UTC](https://www.ruby-forum.com/t/activeresource-issue-rails-2-2/167606/1 "2009-05-10T05:07:09Z")

</div>

I’m doing something like this in a simple test script:  
show\_cc = CreditCard.find(account.credit\_card\_ref, :params =\> {:salt  
=\> salt})  
unless show\_cc.errors.nil? or show\_cc.errors.empty?  
puts “we gots errors : #{show\_cc.errors.to\_yaml}”  
exit  
end  
puts “show card : #{show\_cc.to\_yaml}”

show\_cc.credit\_card\_month = ‘12’  
show\_cc.iv = salt  
show\_cc.cvv = ‘999’  
show\_cc.save  
unless show\_cc.errors.nil? or show\_cc.errors.empty?  
puts “we gots errors : #{show\_cc.errors.to\_yaml}”  
exit  
end

puts "updated card : #{show\_cc.to\_yaml}

CreditCard is a n ActiveResource class. The show\_cc.save is done as a  
create instead of an update. I figured since the show\_cc object is  
first created from a find (show) and then i modify the attributes and  
do a save I should get an update.

I’m on Rails 2.2.  
Thanks.  
Erik

---

<div class="post-metadata">

**Author:** ![erik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b5ac83/32.png) [@erik](https://www.ruby-forum.com/u/erik)\
**Post date:** [May 10, 2009, 5:36am UTC](https://www.ruby-forum.com/t/activeresource-issue-rails-2-2/167606/2 "2009-05-10T05:36:57Z")

</div>

So if found this code in the activeresource code:  
active\_resource/base.rb: new? ? create : update

so a cc.new? if true would call create, and sure enough it is. Anyone  
know why getting something from a find would make the object as new?  
Thanks.  
Erik

---

<div class="post-metadata">

**Author:** ![erik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b5ac83/32.png) [@erik](https://www.ruby-forum.com/u/erik)\
**Post date:** [May 10, 2009, 5:45am UTC](https://www.ruby-forum.com/t/activeresource-issue-rails-2-2/167606/3 "2009-05-10T05:45:43Z")

</div>

Just in-case anyone else runs into this…if you have an object  
without an id, it’s new.  
here is the code  
def new? #line 704 in active\_resource/base.rb  
d.nil?  
end

I was removing the id for a decent reason, but it looks like i’m going  
to need to come up with something else.  
Erik
