I'm not sure about this line. If the user inputs "5", doesn't it mean that he wants 5 units? I think they should be summed to the existing amount, just replace the amount. Something like:

```ruby
 line.update_attributes(:amount => params[:amount].to_i) 
```