User: username regex is a const now
This commit is contained in:
parent
0c1516bb14
commit
b4f0f57df9
|
@ -95,10 +95,8 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.username_regex
|
def self.username_regex_s
|
||||||
User.validators_on(:username).select{|v|
|
"/^" + VALID_USERNAME.to_s.gsub(/(\?-mix:|\(|\))/, "") + "$/"
|
||||||
v.class == ActiveModel::Validations::FormatValidator }.first.
|
|
||||||
options[:with].inspect
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_json(options = {})
|
def as_json(options = {})
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<%= f.label :username, t('.username'), :class => "required" %>
|
<%= f.label :username, t('.username'), :class => "required" %>
|
||||||
<%= f.text_field :username, :size => 15 %>
|
<%= f.text_field :username, :size => 15 %>
|
||||||
<span class="hint">
|
<span class="hint">
|
||||||
<tt><%= User.username_regex %></tt>
|
<tt><%= User.username_regex_s %></tt>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<%= f.label :username, "Username:", :class => "required" %>
|
<%= f.label :username, "Username:", :class => "required" %>
|
||||||
<%= f.text_field :username, :size => 30 %>
|
<%= f.text_field :username, :size => 30 %>
|
||||||
<span class="hint">
|
<span class="hint">
|
||||||
<tt><%= User.username_regex %></tt>
|
<tt><%= User.username_regex_s %></tt>
|
||||||
</span>
|
</span>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue