bernat / best_in_place

A RESTful unobtrusive jQuery Inplace-Editor and a helper as a Rails Gem
http://blog.bernatfarrero.com/in-place-editing-with-javascript-jquery-and-rails-3/
1.2k stars 574 forks source link

as: checkbox value doesn't change on index view #585

Open Lucones opened 6 years ago

Lucones commented 6 years ago

I'm doing a best_in_place for an boolean attribute in my index view table

finance/index.html.erb

<% @finances.each do |finance| %>
  <td><%= finance.receive %></td>           
  <td><%= best_in_place finance, :status, as: :checkbox %> </td>

If I click on it, the status is changed in my db but it doesn't change on my view unless I perform a refresh. Oddly if I do it with the "receive" attribute as an input, it works as intended, changing the value on my db and on my view without the need to refreshing the page.

I'm gueesing it is something with my update response. I've tried several ways of responding in my update controller method, here it is the last one I tried before recurring to this here.

finances_controller.rb

  def update
    @finance = Finance.find(params[:id])
    @finance.update(finance_params)
    respond_with_bip(@finance)
  end

Keep in mind that it works fine with other types of best_in_place (at least with the input one)

jaredjackson commented 5 years ago

I think on the index view the url must be supplied. Try the following...

<%= best_in_place finance, :status, as: :checkbox, url: finance_path(finance) %>