Skip to content

Instantly share code, notes, and snippets.

@jcieslar
Created February 27, 2015 14:03
Show Gist options
  • Save jcieslar/efc9ee9c9301818f7c37 to your computer and use it in GitHub Desktop.
Save jcieslar/efc9ee9c9301818f7c37 to your computer and use it in GitHub Desktop.
Simple form input 'as: integer' brake rails numericality validations
/* wrong */
= f.input :twitter_followers, as: :integer
/* correct */
= f.input :twitter_followers
validates :twitter_followers, numericality: true, if: -> { self.twitter_followers.present? }
# input value: twitter_followers = "Foo"
# wrong option
# return: self.twitter_followers => ""
# correct option
# return: self.twitter_followers => "Foo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment