0
我有一個聯繫表單,當我使用URL加載表單頁面時,工作正常。現在我重新設計了網站,表單現在正在側欄中呈現,當我點擊側邊欄中的提交按鈕時,發現發佈錯誤。補充工具欄形式 - 沒有路由匹配[POST]
現在,如果我使用URL加載表單頁面,只要留在表單頁面上,只要我改變頁面,當我點擊時,側欄表單將會拋出'沒有路由匹配[Post]
'的錯誤提交按鈕。
任何幫助將不勝感激!
斯科特
Rails.application.routes.draw do
root 'static_pages#index'
get 'home' => 'static_pages#index'
get 'video' => 'static_pages#video'
get 'help' => 'static_pages#help'
get 'about' => 'static_pages#about'
get 'services' => 'static_pages#services'
get 'accordion' => 'static_pages#accordion'
get 'social' => 'static_pages#social'
get '/messages' => 'messages#new'
post '/messages' => 'messages#create'
end
Messages_Controller
class MessagesController < ApplicationController
def new
@message = Message.new
end
def create
@message = Message.new(message_params)
if @message.valid?
MessageMailer.new_message(@message).deliver
flash[:notice] = "Your Messages Has Been Sent."
redirect_to messages_path
else
flash[:alert] = "Please Fill in All of the Fields."
render :new
end
end
private
def message_params
params.require(:message).permit(:name, :email, :subject, :content)
end
end