badgeville/badgeville-ruby — pull request #3 by creativeallies (2012-05-29 19:02:24+00:00)
Title: Bugfix for BadgevilleBerlin::BaseResource sanitize_request

There is a bug in the sanitize_request method that prevents objects from being saved. An extra "attributes" in the method chain results in a call against an array. Removing the extra attributes remedied the bug.

Line 30 looks like this:

```ruby
self.attributes[self.attributes.keys[index]] = self.attributes[self.attributes.keys[index]].attributes.to_json
```

where it should be

```ruby
self.attributes[self.attributes.keys[index]] = self.attributes[self.attributes.keys[index]].to_json
```

The backtrace of the bug is as follows:

```ruby
ree-1.8.7-2011.03 :008 > bv.update_player
NoMethodError: undefined method `attributes' for []:Array
from /Users/mindtonic/.rvm/gems/ree-1.8.7-2011.03@creativeallies2-rails31/gems/badgeville_berlin-0.1.1/lib/badgeville_berlin/base_resource.rb:30:in `sanitize_request'
from (irb):8:in `each_with_index'
from /Users/mindtonic/.rvm/gems/ree-1.8.7-2011.03@creativeallies2-rails31/gems/badgeville_berlin-0.1.1/lib/badgeville_berlin/base_resource.rb:28:in `each'
from /Users/mindtonic/.rvm/gems/ree-1.8.7-2011.03@creativeallies2-rails31/gems/badgeville_berlin-0.1.1/lib/badgeville_berlin/base_resource.rb:28:in `each_with_index'
from /Users/mindtonic/.rvm/gems/ree-1.8.7-2011.03@creativeallies2-rails31/gems/badgeville_berlin-0.1.1/lib/badgeville_berlin/base_resource.rb:28:in `sanitize_request'
from /Users/mindtonic/.rvm/gems/ree-1.8.7-2011.03@creativeallies2-rails31/gems/badgeville_berlin-0.1.1/lib/badgeville_berlin/base_resource.rb:22:in `encode'
from /Users/mindtonic/.rvm/gems/ree-1.8.7-2011.03@creativeallies2-rails31/gems/activeresource-3.1.3/lib/active_resource/base.rb:1354:in `update_without_notifications'
from /Users/mindtonic/.rvm/gems/ree-1.8.7-2011.03@creativeallies2-rails31/gems/activeresource-3.1.3/lib/active_resource/observing.rb:19:in `update'
from /Users/mindtonic/.rvm/gems/ree-1.8.7-2011.03@creativeallies2-rails31/gems/activeresource-3.1.3/lib/active_resource/base.rb:1156:in `save_without_validation'
from /Users/mindtonic/.rvm/gems/ree-1.8.7-2011.03@creativeallies2-rails31/gems/activeresource-3.1.3/lib/active_resource/validations.rb:79:in `save_without_notifications'
from /Users/mindtonic/.rvm/gems/ree-1.8.7-2011.03@creativeallies2-rails31/gems/activeresource-3.1.3/lib/active_resource/observing.rb:19:in `save'
from /Users/mindtonic/Sites/creativeallies2/lib/badgeville.rb:57:in `update_player'
from (irb):8
```
The update_player method indicated in the backtrace is a method from my wrapper class, nothing fancy, just an internal api for our purposes:

```ruby
def update_player
@bv_player = BadgevilleBerlin::Player.find( player_id )
@bv_player.picture_url = @ca_user.image
@bv_player.first_name = @ca_user.first_name
@bv_player.last_name = @ca_user.last_name
@bv_player.display_name = @ca_user.display_name
@bv_player.save
end
```

Upon removing the extra "attributes" call, the method works as expected and all of your specs passed.

The other commit is just a little note in your README clarifying the meaning of :host_name. Take or leave that one.