我的表单有两个单选按钮,公共和私人:
<div class='review-form'>
<%= simple_form_for(@review) do |f| %>
# input boxes for current_user to put text here
#'public' radio button, checked by default, class is for css
<%= f.radio_button :visible, "true" , :class => "share_button" %>
#'private' radio button, class is for css
<%= f.radio_button :visible, "false", :class => "keep_private_button" %>
#user can cancel
<%= link_to I18n.t('write_review.cancel_button'), landing_page,
:class => 'btn' %>
#user can submit
<%= f.button :submit, I18n.t('write_review.submit_button'),
:class => 'btn btn-primary' %>
如何确定每条评论中的单选按钮是真还是假,以便在评论保存到我的应用程序后使用它?
例如,类似:
<% if @review.radio_button.value = true %>
<%= label_tag("This review is public") %>
<% end %>
<% if @review.radio_button.value = false %>
<%= label_tag("This review is private") %>
<% end %>