Chuck Han
2012-Dec-18 22:52 UTC
ActiveResource::create with an existing id: Rails 3.0 vs Rails 3.1 and above
I''m upgrading my application from Rails 3.0 to Rails 3.2 (yeah, I know, what happened to 3.1?), and I''m experiencing a difference in the REST call when calling ActiveResource::create where the id is already defined. In 3.0, the app is sending a PUT. In 3.1 and above, is sending a POST. The PUT seemed to make sense to me since the id already exists. Is there any documentation of this change? Am I experiencing something strange? Thanks in advance, Chuck -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/6uZcLFo1VQAJ. For more options, visit https://groups.google.com/groups/opt_out.
Chuck Han
2012-Dec-19 23:09 UTC
Re: ActiveResource::create with an existing id: Rails 3.0 vs Rails 3.1 and above
Well, when in doubt, check the source code. In 3.0, create checks new? which looks to see if id.nil? In 3.1 and above, it also checks new?, but now, new? checks to see if the object has been persisted (which is different from checking to see if id is defined). On Tuesday, December 18, 2012 2:52:18 PM UTC-8, Chuck Han wrote:> > I''m upgrading my application from Rails 3.0 to Rails 3.2 (yeah, I know, > what happened to 3.1?), and I''m experiencing a difference in the REST call > when calling ActiveResource::create where the id is already defined. In > 3.0, the app is sending a PUT. In 3.1 and above, is sending a POST. The > PUT seemed to make sense to me since the id already exists. > > Is there any documentation of this change? Am I experiencing something > strange? > > Thanks in advance, Chuck >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/284Guk_KsnYJ. For more options, visit https://groups.google.com/groups/opt_out.