[英]Rails - What is the purpose of params[:commit]
我注意到,每次將Rails表單發送到服務器時,提交按鈕的名稱(通常是按鈕上顯示的字符串)就被包含在params
哈希中,稱為“ commit”。
例如(最后輸入)
{"utf8"=>"✓",
"authenticity_token"=>"eZABpBuW7afziDMUJtc1BNEKvGyI7NlTd9+NOYqnMxs=",
"order"=>{"name"=>"marco",
"email"=>"marwus@co.xa",
"phone"=>"0839457382",
"collection"=>"0",
"address"=>"18 main street, paarl",
"city"=>"paarl",
"country"=>"South Africa",
"zip"=>"7646",
"instructions"=>""},
"terms"=>"on",
"commit"=>"Next: 3. Payment"}
這樣做的目的是什么?
是我格式不正確的結果嗎?
這是針對此特定示例的我的提交按鈕,取自我的form_for
塊
<%= f.submit 'Next: 3. Payment', :class => 'right button' %>
(班級的right button
來自基礎表格。
它是區分按下哪個提交按鈕的一種方法。 如果您有非常不同的操作,例如:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.