フォーム名(feedback)があり、送信しようとしています。HAML rails form_for POSTメソッドを呼び出さない
ただし、GET HTTPメソッドを呼び出し続けます。私は:メソッド=>:form_forパラメータの投稿を追加しようとしましたが、それでも動作しません。 POSTメソッドを呼び出さない理由を知ることはできますか?
すくい経路:
Prefix Verb URI Pattern Controller#Action
feedbacks POST /feedback(.:format) feedbacks#create
new_feedback GET /feedback/new(.:format) feedbacks#new
root GET/ welcome#index
FeedbacksController
class FeedbacksController < ApplicationController
def create
@feedback = Feedback.new(feedback_params)
@feedback.save
end
def new
@feedback = Feedback.new
end
private
def feedback_params
# params.require(:feedback).permit(: )
end
end
フィードバック/ new.html.haml
.container.col-xs-12.col-sm-8.col-sm-offset-2.col-md-8.col-md-offset-2.col-lg-8.col-lg-offset-2
.WhiteSpace
=fa_icon "coffee 2x"
=fa_icon "coffee 2x"
=fa_icon "coffee 2x"
%h4 Help us serve you better by telling us what you think !
.WhiteSpace
%form.form-horizontal
=form_for(@feedback, :method => :post) do |feedback|
.form-group
%feedback.label_field.col-sm-2.control-label <b>Name</b>
.col-sm-6
=feedback.text_field(:name, :class =>"form-control" ,:placeholder => "Name")
.form-group
%feedback.label_field.col-sm-2.control-label <b>Email (optional)</b>
.col-sm-6
=feedback.text_field(:email, :class => "form-control", :placeholder => "Email")
.form-group
%feedback.label_field.col-sm-2.control-label <b>Tel No. (optional)</b>
.col-sm-6
=feedback.text_field(:telephone_no, :class => "form-control", :placeholder =>"Telephone No.")
-#TODO: Use Ratyrate
.form-group
%h3.col-sm-2.control-label!="<u>Services</u>"
.form-group
%feedback.label_field.col-sm-2.control-label <b>Delivery</b> :
.col-sm-6
=fa_icon "star-o 2x"
=fa_icon "star-o 2x"
=fa_icon "star-o 2x"
=fa_icon "star-o 2x"
=fa_icon "star-o 2x"
.form-group
%feedback.label_field.col-sm-2.control-label <b>Friendliness</b> :
.col-sm-6
=fa_icon "star-o 2x"
=fa_icon "star-o 2x"
=fa_icon "star-o 2x"
=fa_icon "star-o 2x"
=fa_icon "star-o 2x"
.form-group
%feedback.label_field.col-sm-2.control-label <b>Price </b>:
.col-sm-6
=fa_icon "star-o 2x"
=fa_icon "star-o 2x"
=fa_icon "star-o 2x"
=fa_icon "star-o 2x"
=fa_icon "star-o 2x"
.form-group
%feedback.label_field.col-sm-2.control-label <b>Message:</b>
.col-sm-6
=feedback.text_area(:comment, :class => "form-control", :placeholder=> "Comment",:rows =>"10")
.form-group
=feedback.submit("Submit", :class =>"btn-primary btn-lg btn-block")
[送信]をクリックした後の出力は次のようになります。
、 'url:{action:" create "}' – fanta