Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

false values not displayed in show view when compact_show_view is set to true #2416

Closed
benhutton opened this issue Oct 1, 2015 · 1 comment
Milestone

Comments

@benhutton
Copy link

I want to keep compact_show_view = true, which I understand to be defined as "anything non-nil should show up in show view"

I have a boolean field, and thus I want it to show up in show view when it is set to false:

> false.nil?
 => false

The show template does properly use #nil? as the check for whether or not to display values:

- unless values[index].nil? && RailsAdmin::config.compact_show_view

The problem is that the values array is constructed by calling #presence on the formatted_value:

values = fields.map{ |f| f.formatted_value.presence }

Unfortunately,

> false.presence
 => nil

so

> false.presence.nil?
 => true
@begedin
Copy link

begedin commented Mar 22, 2016

👍 for this.

As an additional argument for this being considered a bug, we have a pretty_value defined for the boolean field type at https://github.com/sferik/rails_admin/blob/master/lib/rails_admin/config/fields/types/boolean.rb#L13

register_instance_option :pretty_value do
  case value
  when nil
    %(<span class='label label-default'>&#x2012;</span>)
  when false
    %(<span class='label label-danger'>&#x2718;</span>)
  when true
    %(<span class='label label-success'>&#x2713;</span>)
  end.html_safe
end

@mshibuya mshibuya added this to the 2.0.0 milestone May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants