简单表单下拉菜单,字符串选择
Simple Form drop down menu, string selection
我在 rails 4 应用程序中使用简单的形式。
我的应用程序中有一个显示页面,其中包含此位置标识符:
<div class="datasubtextq">Location:
<span class="datasubtexta">
<% if @project.scope.try(:participant).try(:location_specific) == true %>
<%= render @project.scope.try(:participant).try(:location) %>
<% else %>
<%= render :text => "Remote participation sought" %>
<% end %>
</span>
</div>
在我的表单中,我要求用户select一个位置,如下:
<%= par.input :location, label: 'Where will participants take part in this project?', label_html: {class: 'response-project'}, collection: [ "Brisbane", "Melbourne", "Sydney" ], prompt: "Choose one" %>
当我对此进行测试时,出现以下错误:
The partial name (Brisbane) is not a valid Ruby identifier; make sure your partial name starts with a lowercase letter or underscore, and is followed by any combination of letters, numbers and underscores.
如何要求显示表格以反映表格中制作的位置select?
谢谢
如果您阅读收到的错误,您会发现问题与尝试渲染不存在但没问题的部分有关,解决问题更改
<%= render @project.scope.try(:participant).try(:location) %>
和
<%= @project.scope.try(:participant).try(:location) %>
我在 rails 4 应用程序中使用简单的形式。
我的应用程序中有一个显示页面,其中包含此位置标识符:
<div class="datasubtextq">Location:
<span class="datasubtexta">
<% if @project.scope.try(:participant).try(:location_specific) == true %>
<%= render @project.scope.try(:participant).try(:location) %>
<% else %>
<%= render :text => "Remote participation sought" %>
<% end %>
</span>
</div>
在我的表单中,我要求用户select一个位置,如下:
<%= par.input :location, label: 'Where will participants take part in this project?', label_html: {class: 'response-project'}, collection: [ "Brisbane", "Melbourne", "Sydney" ], prompt: "Choose one" %>
当我对此进行测试时,出现以下错误:
The partial name (Brisbane) is not a valid Ruby identifier; make sure your partial name starts with a lowercase letter or underscore, and is followed by any combination of letters, numbers and underscores.
如何要求显示表格以反映表格中制作的位置select?
谢谢
如果您阅读收到的错误,您会发现问题与尝试渲染不存在但没问题的部分有关,解决问题更改
<%= render @project.scope.try(:participant).try(:location) %>
和
<%= @project.scope.try(:participant).try(:location) %>