Search code examples
ruby-on-railsoptimistic-lockingbest-in-place

ruby on rails + optimistic locking + best_in_place


faced with the problem, the best_in_place bypasses optimistic record locking, just keeps on top of the new value. How can I fix this?


Solution

  • Had the same problem.

    I have some best_in_place fields within a form and I added a hidden field named lock_version and it seems to work.

    <%= form_for(commission, :remote => true) do |f| %>
       <%= best_in_place commission, :commission_MA if admin? %>
       <%= f.hidden_field :lock_version %>
    <% end %>
    

    Hope that solves the problem for you as well.