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 571 forks source link

Possible to use :display_with and :nil together? #497

Open behindcurtain3 opened 9 years ago

behindcurtain3 commented 9 years ago

Here is the code I'm trying to use:

<%= best_in_place_if user_signed_in?, @movie, :runtime, :as => :input,
      :display_with => lambda {|v| t('movie.runtime.data', :length => v) },
      :nil => t('movie.unknown'),
      :inner_class => 'form-control' %>

and

<%= best_in_place_if user_signed_in?, @movie, :released, :as => :date,
    :display_with => :time_tag,
    :nil => t('movie.unknown'),
    :inner_class => 'form-control' %>

On both of those examples the nil portion never fires. It seems to be overwritten by the :display_with option. I did this in another portion of my code and it works fine:

<%= best_in_place_if user_signed_in?, @movie, :summary, :as => :textarea,
    :inner_class => 'form-control', :nil => t('movie.unknown') %>

Am I doing something wrong or could someone help me with what I'm missing here?