ransack 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -53,16 +53,8 @@ module Ransack
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def type_for(attr)
|
56
|
-
return nil unless attr
|
57
|
-
|
58
|
-
table = attr.relation.name
|
59
|
-
|
60
|
-
unless @engine.connection.table_exists?(table)
|
61
|
-
raise "No table named #{table} exists"
|
62
|
-
end
|
63
|
-
|
64
|
-
# TODO: optimize
|
65
|
-
@engine.connection.columns(table).detect {|c| c.name == name}.type
|
56
|
+
return nil unless attr && attr.valid?
|
57
|
+
klassify(attr.parent).columns_hash[attr.arel_attribute.name.to_s].type
|
66
58
|
end
|
67
59
|
|
68
60
|
private
|
@@ -51,9 +51,9 @@ module Ransack
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def type_for(attr)
|
54
|
-
return nil unless attr
|
55
|
-
name = attr.name.to_s
|
56
|
-
table = attr.relation.table_name
|
54
|
+
return nil unless attr && attr.valid?
|
55
|
+
name = attr.arel_attribute.name.to_s
|
56
|
+
table = attr.arel_attribute.relation.table_name
|
57
57
|
|
58
58
|
unless @engine.connection_pool.table_exists?(table)
|
59
59
|
raise "No table named #{table} exists"
|
data/lib/ransack/version.rb
CHANGED