Q:

Rails check_box: checked if for a new record?

In a Rails 4 form_for form, I'm have:
f.check_box :visible
I want the checkbox to be rendered as checked when rendering the form for a brand new (ie unsaved) object.
When the object is saved, I want the checkbox to behave normally (ie be checked or not checked based on the value of the saved object).
This works:
f.object.new_record? ? (f.check_box :visible, :checked => true) : (f.check_box :visible)
.. but it's pretty long! Is there a simpler/better way I can accomplish this?

A:

f.check_box :visible, checked: ( f.object.new_record? || f.object.visible )

