[英]How to submit and display form data onto another page in rails without using controllers?
I have a form which takes various inputs and when clicking on submit it should display those params data on to another page. 我有一个接受各种输入的表单,单击“提交”时,应将这些参数数据显示在另一页上。 For example, I have a form called enter_invoice.html.erb
例如,我有一个名为enter_invoice.html.erb的表单
I have written the following html code for it. 我已经为它编写了以下html代码。
<%= form_tag('/generate_invoice', remote: true, multipart: true, type: :post )
do |f| %>
<input type="text" name="order[txnid]" placeholder="Enter your txnid" /><br>
<input type="number" name="order[stamp_amount]" placeholder="Stamp amount" />
<br>
<input type="text" name="order[payment][created_at][strftime]"
placeholder="Payment Created at" /><br>
<input type="text" name="order[payment][mode]" placeholder="Payment mode" />
<br>
<input type="text" name="order[user][profile][first_name]" placeholder="User
First name" /><br>
<input type="submit" class="submit action-button" /><br>
<% end %>
Now I have another form called genrate_invoice.html.erb.The data I enter in enter_invoice should display on generate_invoice. 现在我有了另一个名为genrate_invoice.html.erb的表格。我在enter_invoice中输入的数据应该显示在generate_invoice上。
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body style="margin:0 auto;padding:0;max-width:595px;font-family:
'PFBeauSansPro' 'Tahoma';font-weight:thin;font-size: 14px;background-size:
cover;ont-family: 'PFBeauSansPro';font-weight: thin !important;">
TNXid : <%= @order.txnid %><br>
Stamp_amount : <%= @order.stamp_amount %> <br/>
Created_at : <%= @order.payment.created_at.strftime %> <br/>
Address: <%= @order.address.address1 %><br/>
:
:
</body>
</html>
So how do I submit this data to be displayed on the generate_invoice.html.erb. 因此,我该如何提交要显示在generate_invoice.html.erb上的数据。
Newbie still in rails. 新手仍然处于困境。 Please guide me.
请指导我。
I think what you are trying to do is input data into a single object in a number of steps. 我认为您要尝试的步骤是将数据输入到单个对象中。 Avoiding controllers is not the best solution.
避免使用控制器不是最佳解决方案。
If you are new to rails, I'd suggest you have a look at the wicked gem . 如果您不熟悉铁轨,我建议您看看邪恶的宝石 。 That will help you build a multi-step input.
这将帮助您建立多步输入。
Alternatively, you can build you own solution by: 或者,您可以通过以下方式构建自己的解决方案:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.