建立一个Rails表单来过滤索引页面? [英] Building a rails form to filter an index page?

查看:40
本文介绍了建立一个Rails表单来过滤索引页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

天大的家伙",我在过滤系统中存在的数千种贸易项目的展示时遇到问题.根据我们正在构建的系统的规格,我们必须具有一种表格,该表格允许人们输入开始日期,然后以分钟为单位的时间间隔,以过滤项目的表示形式.我已经建立了辅助函数来返回该间隔时间内的所有交易,但是我无法终生正确地建立将在索引页面顶部返回dateTime值和整数值的表格吗?

G'day guys, I'm having an issue with filtering the presentation of several thousand trade items I have in my system. As per the specs of the system we're building we have to have a form that allows people to put in a start date and then an interval in minutes, to filter the presentation of the items. I've built my helper functions to return all of the trades within that interval period, but I can't for the life of me properly build the form that will return a dateTime value and an integer value within the top of the index page?

有什么想法吗?我是否需要构建一个单独的模型对象来为其分配值,还是有一种更简单的方法?

Any ideas? Would I have to build a separate model object to assign values to, or is there a simpler way?

推荐答案

在索引页上,您可以创建这样的过滤器表单

On your index page you can create a filter form like this

<%= form_tag '', :method => :get do %>
  <%= text_field_tag :value_one %>
  <%= text_field_tag :value_two %>
  <%= submit_tag 'Filter' %>
<% end %>

然后,您的表单将使用查询字符串参数在页面上执行GET,然后在您的控制器中查找可能已传递的过滤器参数.

Your form will then do a GET on your page with query string parameters and then in your controller you can look for the filter parameters that might have been passed.

这篇关于建立一个Rails表单来过滤索引页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆