Is there a cleaner way of selecting a radio_button by default or if it was previously selected in one line of code?
I first tried this:
- if @job.new_record?
= f.radio_button :environment_id, env.id, :checked => env.is_default
- else
= f.radio_button :environment_id, env.id, :checked => @job.environment == env
I tried to refactor using this:
= f.radio_button :environment_id, env.id, :checked => (@job.andand.environment == env) || env.is_default
but the problem with that is if the default selection is AFTER the job's environment, it will select the default selection.
Any other suggestions?