if @challenge.name == 'foo'
@challenge.category = 'habit'
@challenge.days_challenged = 21
@challenge.why = 'bar'
else
:days_challenged
& :why
正确的_form为foo
被设置但不:category
。默认对象属性不默认为HTML
<div class="challenge-category">
<input class="date-format-switcher" type="radio" value="goal" name="challenge[category]" id="challenge_category_goal">
<label for="challenge_category_goal">Goal</label>
<input class="date-format-switcher" type="radio" value="habit" name="challenge[category]" id="challenge_category_habit">
<label for="challenge_category_habit">Habit</label>
</div>
<%= f.number_field :days_challenged, class: 'day-challenge' %>
<%= f.text_area :why %>
快,让你的控制器的方法,并查看完整的代码 – Ilya