首页 > 代码库 > form_tag

form_tag

class SwitchesController < ApplicationController  #before_filter :authenticate_user!, :except => [:index, :show]  def index  end  def show  end  #存储拓扑  def topo    @vts = VmToSwitch.all    @sts = SwitchToSwitch.all    @stvs = SwitchToVswitch.all  end  #监控  def monitor    @switches = [["S1","s1v"],["S2","s2v"]]    @select_value = http://www.mamicode.com/params[:people]>

  

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><%= render partial: ‘bar‘ %><b>hello monitor</b><%= form_tag("monitor") do |f| %><%= select_tag "people", options_for_select(@switches), prompt: "Select something" %><%= submit_tag("Search") %><% end %></br><b>your choice:</b><%= @select_value %>

  

突然才发现form_for 和 form_tag是有区别的

form_tag 可以不用绑定model类直接取得数据。。。对于简单的这种选择响应再好不过

 

form_for能不能不绑定model还有待学习