Validate non-model field

前端 未结 2 1855
慢半拍i
慢半拍i 2021-01-18 04:28

I\'ve added an extra field to my new form:

<%= select_tag :quantity, options_for_select([\"Select a Value\"].concat((1..10).to_a)) %>
         


        
2条回答
  •  无人共我
    2021-01-18 04:53

    Found. You may want to add a virtual attribute in the model.

    .........
    
    attr_accessor :not_on_db
    .........
    
    validates_presence_of     :not_on_db,
    validates_length_of       :not_on_db,    :within => 1..5
    .........
    

提交回复
热议问题