fabrik42/acts_as_api — Issue #57: Wrong field order
Author: rgorel
Created: 2012-01-26 19:48:52+00:00
State: open

Hello,

First of all many thanks for your awesome gem, it could save a lot of my time if only I could find it earlier :)

So the problem is that my model fields are ordered wrong in JSON or XML output.

I have this in my model:

```ruby
api_accessible :full_profile do |t|
t.add :id
t.add :username
t.add :status
t.add :text_status
t.add :status_updated_at
t.add lambda {|user| user.picture.url(:medium)}, :as => :picture
t.add :age
t.add :sliders
t.add :bio
t.add :lat
t.add :long
t.add :registered_time_ago
t.add :is_blocked, :if => lambda {|u| !u.is_blocked.nil?}
t.add :is_favorite, :if => lambda {|u| !u.is_favorite.nil?}
end
```

And this is what I have in XML output:

```xml

1
/system/pictures/1/medium/various_human_21.jpg

39.7756093397402
-73.1707363222342

user1

1

1 day

```

I am writing a web service for iOS app, and the iOS developer says that each time I deploy the code the fields are ordered in some random way, and it messes things up. The strict order is important for the XML parsing library that he uses.

Is there any solutions for this issue?

Thanks.