渲染导轨输出

时间:2015-06-01 10:28:35

标签: ruby-on-rails simple-form

我正在尝试在我的Rails 4应用程序中设置我的简单表单输出。

我有一个项目模型,一个范围模型和一个参与者模型。

参与者属于范围。范围属于项目。

参与者模型有两个属性 - 一个用于'location_specific',它是一个布尔值,一个用于'location',它是一个字符串。

如果location_specific为true,那么我想输出所需的位置。

在我的参与者展示部分,我有:

<div class="datasubtextq">Location:
        <span class="datasubtext">
          <% if @project.scope.participant.location_specific == true %>
            <%=  @project.scope.participant.location %>
          <% else %>
            <%= render :text => "Remote participation" %>
          <% end %>
        </span>
  </div>

在我的表格中,我有:

  <div class="row">
        <div class="col-md-3 col-md-offset-1">
          <%= f.label 'Can participants participate remotely?', :class => 'question-project' %>
        </div>
        <div class="col-md-7">
          <%= par.collection_radio_buttons :location_specific, [[true, ' Yes'], [false, ' No']], :first, :last, {:item_wrapper_class => 'fixradio'}, {:class => "response-project"} %>
        </div>
      </div>

      <div id="requiredlocation">

        <div class="row">
          <div class="col-md-3 col-md-offset-1">
            <%= f.label 'Select participation location', :class => 'question-project' %>
          </div>
          <div class="col-md-7">
            <div class="response-project">
            <%= par.select :location,
                           options_for_select(["New York", "Boston", "Florida"]),
                           label: 'Where will participants take part in this project?',
                           prompt: "Choose one",
                           class: 'response-project' %>
          </div>
        </div>
        </div>
      </div>

我的问题是,每次尝试这个,我都会得到'远程参与的选择。 “城市”选项未按预期显示。关于我做错了什么的想法?

谢谢

0 个答案:

没有答案