lib/rails_erd/domain/attribute.rb in rails-erd-1.2.2 vs lib/rails_erd/domain/attribute.rb in rails-erd-1.3.0

- old
+ new

@@ -47,11 +47,11 @@ !column.null or @model.validators_on(name).map(&:kind).include?(:presence) end # Returns +true+ if this attribute is the primary key of the entity. def primary_key? - column.primary + @model.primary_key.to_s == name.to_s end # Returns +true+ if this attribute is used as a foreign key for any # relationship. def foreign_key? @@ -98,15 +98,17 @@ end # Returns any non-standard limit for this attribute. If a column has no # limit or uses a default database limit, this method returns +nil+. def limit - column.limit.to_i if column.limit != native_type[:limit] and column.limit.respond_to?(:to_i) + return column.limit.to_i if column.limit != native_type[:limit] and column.limit.respond_to?(:to_i) + column.precision.to_i if column.precision != native_type[:precision] and column.precision.respond_to?(:to_i) end # Returns any non-standard scale for this attribute (decimal types only). def scale - column.scale.to_i if column.scale != native_type[:scale] and column.scale.respond_to?(:to_i) + return column.scale.to_i if column.scale != native_type[:scale] and column.scale.respond_to?(:to_i) + 0 if column.precision end # Returns a string that describes the limit for this attribute, such as # +(128)+, or +(5,2)+ for decimal types. Returns nil if no non-standard # limit was set.