How do I make Rails treat the “http://” value as blank: if the value is “http://”, do not validate website field and insert an empty string (not “http://”) into database?
In view:
<%= f.text_field :website, value: "http://" %>
In model:
validates :website, format: { with: /^https?:\/\/\S+/i }, allow_blank: true
You can use :if or :unless to conditionally validate (untested):
Use a before_save callback to convert the string to blank: