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

On May 9, 8:35 pm, erik <[email protected]> wrote:
> 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
>
> On May 9, 8:06 pm, erik <[email protected]> wrote:
>
> > 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
>
>
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to