Rails Validator - Only Alphanumeric and not all Numeric

ruby, ruby-on-rails, ruby-on-rails-4, validation

Solution

You can use

validates :user_name, with: /^[A-Za-z0-9]+$/

which accepts only number and digits or you can try Rails format validation -- alphanumeric, but not purely numeric

Problem

I'm trying to get a 'Twitter-like' validation working. That means ``` - Only alphanumeric and not all numeric ``` but I'm stuck at the regexp. Can someone help me out with that specific regular expression? `validates :user_name, with: 'elmagicoregexp'`

Original source

Related problems