2013-09-30 79 views
2

我使用簡單形式的寶石來呈現我的表單。我正在嘗試將輸入字段類型設置爲'數字'。此代碼不起作用:簡單表單輸入類型

f.input :amount, input_html: { type: 'number' } 

什麼是正確的方法來設置它?

回答

5

下面應該工作

f.input :amount, :input_html => { :type => "number" } 

一個更清潔的方式是:

f.input :amount, :as => "number" 

希望它能幫助!

2

嘗試:

f.input :amount, as: :integer 
4

簡單的方法:

f.input :whatever, as: :numeric