forked from fixin.me/fixin.me
Replace #columns_hash with #type_for_attribute for limits
This commit is contained in:
parent
15a5515c99
commit
0b201606c2
@ -10,8 +10,8 @@ class Unit < ApplicationRecord
|
||||
errors.add(:base, :multilevel_nesting) if base.base.present?
|
||||
end
|
||||
validates :symbol, presence: true, uniqueness: {scope: :user_id},
|
||||
length: {maximum: columns_hash['symbol'].limit}
|
||||
validates :description, length: {maximum: columns_hash['description'].limit}
|
||||
length: {maximum: type_for_attribute(:symbol).limit}
|
||||
validates :description, length: {maximum: type_for_attribute(:description).limit}
|
||||
validates :multiplier, numericality: {equal_to: 1}, unless: :base
|
||||
validates :multiplier, numericality: {other_than: 0, precision: true, scale: true}, if: :base
|
||||
|
||||
|
@ -14,8 +14,8 @@ class User < ApplicationRecord
|
||||
has_many :units, dependent: :destroy
|
||||
|
||||
validates :email, presence: true, uniqueness: true,
|
||||
length: {maximum: columns_hash['email'].limit}
|
||||
validates :unconfirmed_email, length: {maximum: columns_hash['unconfirmed_email'].limit}
|
||||
length: {maximum: type_for_attribute(:email).limit}
|
||||
validates :unconfirmed_email, length: {maximum: type_for_attribute(:unconfirmed_email).limit}
|
||||
|
||||
def to_s
|
||||
email
|
||||
|
@ -4,11 +4,11 @@
|
||||
|
||||
<td class="<%= class_names({subunit: @unit.base}) %>">
|
||||
<%= form.text_field :symbol, form: :unit_form, required: true, autofocus: true, size: 12,
|
||||
maxlength: @unit.class.columns_hash['symbol'].limit, autocomplete: "off" %>
|
||||
maxlength: @unit.class.type_for_attribute(:symbol).limit, autocomplete: "off" %>
|
||||
</td>
|
||||
<td>
|
||||
<%= form.text_area :description, form: :unit_form, cols: 30, rows: 1, escape: false,
|
||||
maxlength: @unit.class.columns_hash['description'].limit, autocomplete: "off" %>
|
||||
maxlength: @unit.class.type_for_attribute(:description).limit, autocomplete: "off" %>
|
||||
</td>
|
||||
<td>
|
||||
<% unless @unit.base.nil? %>
|
||||
|
Loading…
x
Reference in New Issue
Block a user