我正在使用设计,我正在尝试将下拉菜单的选定值传递给函数,但它不起作用。数据存储在名为 user 的模型中。
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<%= f.select :role, options_for_select([["Job Seeker", "candidate"], ["Employer", "employer"], ["Recruiter", "recruiter"]]) %>
<% if params[:role] == "candidate" %>
<div><%= f.label :travel %><br />
<%= f.text_field :travel %></div>
<% end
if params[:role] == "employer" || params[:role] == "recruiter"
%>
<div><%= f.label :company %><br />
<%= f.text_field :company %></div>
<% end %>
<% end %>