Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed the scopes

  • Loading branch information...
commit acf6e6afa871717feb403919782251d5827b5faa 1 parent a9f93d8
@anga authored
Showing with 11 additions and 8 deletions.
  1. +1 −0  lib/extend_at.rb
  2. +10 −8 lib/extend_at/model_manager.rb
View
1  lib/extend_at.rb
@@ -390,6 +390,7 @@ def get_type_for_class(type)
def compatible_type(value,type)
return true if value.class == String and [:string, :text, :binary].include? type
return true if value.class == Fixnum and [:integer, :float].include? type
+ return true if [Fixnum, Float].include? value.class and [:integer, :float].include? type
return true if [true.class, false.class].include? value.class and [:boolean].include? type
return true if value.class == BigDecimal and [:decimal].include? type
return true if [Date, Time].include? value.class and [:date, :time].include? type
View
18 lib/extend_at/model_manager.rb
@@ -114,14 +114,16 @@ def search(column, method,value)
equivalence_method = EQUIVALENCE_METHODS[method.to_s]
"
where(
- ExtendAt.arel_table.project('model_id').where(
- ExtendAt.arel_table[:model_type].eq(\"#{@model.class.name}\").and(
- ExtendAt.arel_table[:id].in(
- ::Column.arel_table.project('extend_at_id').where(
- ::Column.arel_table[:id].in(
- ::#{type_class}.arel_table.project('extend_at_column_id').where(
- ::#{type_class}.arel_table[:column].eq(column).and(
- ::#{type_class}.arel_table[:value].#{equivalence_method}(value)
+ ::#{@model.class.name}.arel_table[:id].in(
+ ExtendAt.arel_table.project('model_id').where(
+ ExtendAt.arel_table[:model_type].eq(\"#{@model.class.name}\").and(
+ ExtendAt.arel_table[:id].in(
+ ::Column.arel_table.project('extend_at_id').where(
+ ::Column.arel_table[:id].in(
+ ::#{type_class}.arel_table.project('extend_at_column_id').where(
+ ::#{type_class}.arel_table[:column].eq(column).and(
+ ::#{type_class}.arel_table[:value].#{equivalence_method}(value)
+ )
)
)
)
Please sign in to comment.
Something went wrong with that request. Please try again.