简体   繁体   English

Rails表单提交到新页面

[英]Rails form submit to new page

If I have a form taking a collection of names, a date, and another boolean via virtual attributes how can I submit them to a new page and action. 如果我有一个通过虚拟属性接收名称,日期和另一个布尔值的表单,如何将它们提交到新页面和操作。 That has nothing to do with CRUD. 与CRUD无关。 It will simply do some processing then spit out the values on a new page. 它将仅进行一些处理,然后将值吐出到新页面上。

personsSelection.erb 人员选择

<%= render :partial => 'myForm' %>

_myForm.html _myForm.html

<%= simple_form_for(@person) do |f| %>
<%= f.input :names, :collection => People.all, as => :check_boxes %>
<%= f.input :DateTime %>
<%= f.check_box :paid %>
<%= f.submit %>

person_controller.erb person_controller.erb

def personReport
  #Some Random Processing
end

personReport.html.erb personReport.html.erb

#Display the personReport processing data

Again, I'm trying to submit the form to process via personReport action then display to a new page called personReport.html.erb 再次,我尝试通过personReport操作提交表单以进行处理,然后显示到名为personReport.html.erb的新页面

In your routes 在您的路线上

  match "/person/personreport" => "person#personReport", :as => personreport

In your form 以您的形式

  <%= simple_form_for(@person, :url => personreport_path) do |f| %>

This will send the data to your personReport action where you can process the data then by default that action will render personReport.html.erb 这会将数据发送到您的personReport操作,您可以在其中处理数据,然后默认情况下该操作将呈现personReport.html.erb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM