I have ternary operator and I am trying this ternary operator put into checkbox, but I am still making fault in writing (syntax error)…
So I would like to ask about help, how to do…
CAR: <%= f.check_box :car, :value => 2, ((f.sex == 2) ? (:checked => true) : (:checked => false)) %>
You don’t need a ternary operator here. Try this instead:
CAR: <%= f.check_box :car, :value => 2, :checked => (f.sex == 2) %>Also your problem comes from the fact that in a
Hashliteral you can’t define keys conditionally, so:{:a => (:b || :c)}is valid{:b ? (a: => :b) : (:a => :c)}is invalid