我想做一个联系表单,但我收到路由错误。
;WITH cte AS
(
SELECT t1.IDK,
t1.CODE,
t1.NAME,
t2.QTY
FROM Table1 t1
LEFT JOIN Table2 t2
ON t1.IDK = t2.IDK
);
SELECT t.CODE
FROM cte t
WHERE t.NAME = 'PEN' AND
t.QTY = (SELECT MAX(QTY) FROM cte WHERE NAME = 'PEN')
我的观点(contato.html.erb):
No route matches [GET] "/contato"
我的控制器(pages_controller.erb):
class PagesController< ApplicationController中
<%= form_tag(contato_path, method: :post) %>
<div class="row">
<div class="col-md-12">
<%= text_field_tag 'name', placeholder: "Name", class: "form-control" %>
</div>
</div>
<div class="row">
<%= submit_tag 'Send' %>
</div>
<% end %>
路线:
def home
.....
end
def search
.....
end
def contato
.....
end
end
耙路线:
post '/contato' => 'pages#contato'
答案 0 :(得分:1)
问题是您正在尝试在contato.html.erb
中显示未定义GET
请求的表单。不要对GET
和POST
请求使用相同的操作。
创建一个新动作以显示表单
def new
#renders new.html.erb
end
将以下路线添加到routes.rb
get '/new' => 'pages#new'
将表单移至new.html.erb
,然后在contato
操作