lefnire/habitrpg — pull request #1431 by paglias (2013-09-05 13:55:29+00:00)
Title: Market (not working)

The market is almost complete but I get an error when I try to update `user.balance` on the server using `User.log` it complains about `user.balance` being a protected path.

![schermata del 2013-09-05 15 33 22](https://f.cloud.github.com/assets/589911/1088393/cedf4986-1631-11e3-870b-4a8014e91bd3.png)

The `500` error is displayed only on the server's console, in the browser the return code is `200`.

------------------------------------------

In the screenshot above the server complains also about `items.eggs` being an object (it happens every time I try to update items.eggs/pets/hatchingPotions) but anyway the database is updated correctly.

The problem here is that `items.eggs` is an array not an oobject;

![schermata del 2013-09-05 15 32 33](https://f.cloud.github.com/assets/589911/1088425/6f0e1b94-1632-11e3-91f7-9e12a370f9c3.png)

And indeed if you look at the database is correctly saved as an array.

---------------------------------------------

After that someone solves the problem above, before merging, double check that the gems's number is correctly updated immediately by angular and not after the batch update is returned from the server. It may be needed to add something like:

`User.user.balance = (gems - item.value) / 4`