parent
1e24b60906
commit
cb84f7f7b5
|
@ -21,8 +21,8 @@ module Ransack
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid?
|
def valid?
|
||||||
bound? && attr &&
|
bound? && attr && context.klassify(parent)
|
||||||
context.klassify(parent).ransackable_attributes(context.auth_object).include?(attr_name)
|
.ransackable_attributes(context.auth_object).include?(attr_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def type
|
def type
|
||||||
|
|
|
@ -5,7 +5,9 @@ module Ransack
|
||||||
attr_accessor :parent, :attr_name
|
attr_accessor :parent, :attr_name
|
||||||
|
|
||||||
def attr
|
def attr
|
||||||
@attr ||= ransacker ? ransacker.attr_from(self) : context.table_for(parent)[attr_name]
|
@attr ||= ransacker ?
|
||||||
|
ransacker.attr_from(self) :
|
||||||
|
context.table_for(parent)[attr_name]
|
||||||
end
|
end
|
||||||
alias :arel_attribute :attr
|
alias :arel_attribute :attr
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,9 @@ module Ransack
|
||||||
end
|
end
|
||||||
|
|
||||||
def name_from_attribute_name(attribute_name)
|
def name_from_attribute_name(attribute_name)
|
||||||
names_by_decreasing_length.detect { |p| attribute_name.to_s.match(/_#{p}$/) }
|
names_by_decreasing_length.detect {
|
||||||
|
|p| attribute_name.to_s.match(/_#{p}$/)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def for_attribute_name(attribute_name)
|
def for_attribute_name(attribute_name)
|
||||||
|
|
Loading…
Reference in New Issue