mirror of
https://github.com/activerecord-hackery/ransack.git
synced 2022-11-09 13:47:45 -05:00
Make sure we are using the adapter's column hash in AR 3.0
This commit is contained in:
parent
cef7b8ecea
commit
ee84a09337
5 changed files with 8 additions and 15 deletions
|
@ -53,16 +53,8 @@ module Ransack
|
|||
end
|
||||
|
||||
def type_for(attr)
|
||||
return nil unless attr
|
||||
name = attr.name.to_s
|
||||
table = attr.relation.name
|
||||
|
||||
unless @engine.connection.table_exists?(table)
|
||||
raise "No table named #{table} exists"
|
||||
end
|
||||
|
||||
# TODO: optimize
|
||||
@engine.connection.columns(table).detect {|c| c.name == name}.type
|
||||
return nil unless attr && attr.valid?
|
||||
klassify(attr.parent).columns_hash[attr.arel_attribute.name.to_s].type
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -51,9 +51,9 @@ module Ransack
|
|||
end
|
||||
|
||||
def type_for(attr)
|
||||
return nil unless attr
|
||||
name = attr.name.to_s
|
||||
table = attr.relation.table_name
|
||||
return nil unless attr && attr.valid?
|
||||
name = attr.arel_attribute.name.to_s
|
||||
table = attr.arel_attribute.relation.table_name
|
||||
|
||||
unless @engine.connection_pool.table_exists?(table)
|
||||
raise "No table named #{table} exists"
|
||||
|
|
|
@ -26,7 +26,7 @@ module Ransack
|
|||
if ransacker
|
||||
return ransacker.type
|
||||
else
|
||||
context.type_for(attr)
|
||||
context.type_for(self)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ module Ransack
|
|||
def attr
|
||||
@attr ||= ransacker ? ransacker.attr_from(self) : context.table_for(parent)[attr_name]
|
||||
end
|
||||
alias :arel_attribute :attr
|
||||
|
||||
def ransacker
|
||||
klass._ransackers[attr_name]
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module Ransack
|
||||
VERSION = "0.2.0"
|
||||
VERSION = "0.2.1"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue