Let's say I have 2 rails app, a "server" and a "client" for a REST resource.
When you create a new ActiveRecord, you have all attributes whit its defaults values on place:
Article.new # On "server" application
=> #<Article id: nil, name: nil, description: nil, price: nil, created_at: nil, updated_at: nil>
Let's compare that with what happens when we create an ActiveResource on client:
Article.new
=> #<Article:0xb7735124 @prefix_options={}, @attributes={}>
Where do the "id", "name", "description", "price", etc... attributes went? When creating a record, it does not initialize the attributes.
In my opinion, the best way to fix this would be to request a new record to the "server" application via a HTTP request. That way the attributes names of the resource would return it's default values. In my "server" app, requesting http://localhost:3000/articles/new.xml responds the right thing:
<article> <created-at type="datetime" nil="true"/> <description nil="true"/> <name nil="true"/> <price type="decimal" nil="true"/> <updated-at type="datetime" nil="true"/> </article>
There's a caveat for this: making a request in every "new" is expensive for both server and client. In the end, I think this is the right solution anyway.
Someone made a PATCH to "fix" the problem (http://dev.rubyonrails.org/ ticket/9862), although the proposed solution is not the ideal IMHO.
What's your opinion?