0

I have a trouble to show an result of boolean value in a view
I want to show enable and disable but show true or false

my code in index.html.slim

      th Active?  
          td = plan.enable

my code in show.html.slim

   p
    strong Active ?:
    = @plan.enable

How i can solve this?

1 Answers1

2

You should look into a ternary. How do I use the conditional operator (? :) in Ruby?

plan.enable? ? 'Enabled' : 'Disabled'

You could do something like that in your view.

Community
  • 1
  • 1
dasnixon
  • 988
  • 7
  • 18