开发者

configuring username format in authlogic

How can I configure username to only have alphabets (a-z, A-Z), numericals (0-9) and underscores (_) and no other charac开发者_运维问答ters...


validates_format_of :username, :with => /^[A-Za-z\d_]+$/

You can change that to be whatever you want, but just using normal rails validations seems appropriate. Above allows digits, A-Z, a-z, and underscores


I think I found the answer...


acts_as_authentic do |c|
  c.validates_format_of_login_field_options = {:with => /^[a-zA-Z0-9_]+$/, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers and underscores no other characters.")}
end

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜