zoukankan      html  css  js  c++  java
  • 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 = params[:people]
      end
    
    end
    

      

    <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还有待学习

  • 相关阅读:
    寒假13
    寒假作业十二
    寒假12
    寒假作业十一
    寒假11
    寒假作业九
    寒假10
    寒假作业九
    寒假9
    寒假作业八
  • 原文地址:https://www.cnblogs.com/juandx/p/3896160.html
Copyright © 2011-2022 走看看