【发布时间】:2016-08-15 07:40:45
【问题描述】:
if @challenge.name == 'foo'
@challenge.category = 'habit'
@challenge.days_challenged = 21
@challenge.why = 'bar'
else
:days_challenged & :why 正确设置在 foo 的 _form 中,但不是 :category。
<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 %>
【问题讨论】:
-
请展示您的控制器方法并查看完整代码
标签: html ruby-on-rails ruby attributes radio-button