Ruby on rails 获取控制器rails中的select标记值
大家好,我不知道如何在视图中使用select标记并在rails的控制器中获取所选值。我试过一些东西,但没有结果。请有人帮帮我。提前谢谢 index.html.erbRuby on rails 获取控制器rails中的select标记值,ruby-on-rails,ruby-on-rails-4,Ruby On Rails,Ruby On Rails 4,大家好,我不知道如何在视图中使用select标记并在rails的控制器中获取所选值。我试过一些东西,但没有结果。请有人帮帮我。提前谢谢 index.html.erb <%=form_for :law, url: display_lawyers_path do |l|%> <h3>Enter the Location</h3> <%= l.select(:loc, options_for_select(@city.col
<%=form_for :law, url: display_lawyers_path do |l|%>
<h3>Enter the Location</h3>
<%= l.select(:loc, options_for_select(@city.collect {|c| [c.Location, c.id]}))%>
<h3>Enter the Service</h3>
<%= l.select(:ser, options_for_select(@service.collect{|s| [s.Service_Name, s.id]}))%>
<div>
<%= l.submit :submit %>
</div>
<%end%>
你的实际问题是什么?当我执行“渲染文本:@loc”时,我会看到一个空白屏幕。我正在等待所选的位置。
def index
@city = Lawyerscitylist.select(:Location).uniq
@service = Lawyersservicelist.select(:Service_Name).uniq
end
def display
@loc = params[:law][:loc]
render text: @loc
end