Rails update attributes fails




















Improve this answer. Community Bot 1 1 1 silver badge. EnabrenTane EnabrenTane 7, 2 2 gold badges 25 25 silver badges 44 44 bronze badges. What function does it serve? You must have save working, which updates the database. I have never encountered a situation where I had to do that. You have my sympathies. Sounds like you should rethink your database design sooner rather than later. This would be like if I had the constraint of fueling my car, only by walking to the gas station and bringing gas back home to my car.

Would that method work? Is it painful? Show 1 more comment. So just use this construction def update if buyer. APIdock copyright Nodeta Oy RSpec Ruby Ruby on Rails. Flowdock method. Ruby on Rails latest stable v5. Method deprecated or moved This method is deprecated or moved on the latest stable version.

Register or log in to add new notes. Each one does it slightly differently with sometimes unique side-effects. This article has been updated for Rails 4. This regular assignment is the most common and easiest to use. It is the default write accessor generated by Rails. The name attribute will be marked as dirty and the change will not be sent to the database yet. You can undo the change by calling reload!

This is the method that is called by the default accessor above. Updates a single attribute and saves the record without going through the normal validation procedure.

This is especially useful for boolean flags on existing records. With the addition of ActiveRecord::Dirty, the update statement will only feature changed columns, as opposed to the comment of railsmonk below. Take this in account.



0コメント

  • 1000 / 1000