ransack: undefined method `gsub' for 198:Fixnum

{"q"=>{"g"=>{"0"=>{"m"=>"or", "c"=>{"0"=>{"a"=>{"0"=>{"name"=>"release_year"}}, "p"=>"cont", "v"=>{"0"=>{"value"=>"198"}}}}}}}, "limit"=>"50"}
A NoMethodError occurred in playlists#preview:

 undefined method `gsub' for 198:Fixnum
 ransack (0.7.2) lib/ransack/constants.rb:26:in `escape_wildcards'
 ransack (0.7.2) lib/ransack/constants.rb:26:in `escape_wildcards'
 ransack (0.7.2) lib/ransack/constants.rb:9:in `block in <module:Constants>'
 ransack (0.7.2) lib/ransack/predicate.rb:59:in `call'
 ransack (0.7.2) lib/ransack/predicate.rb:59:in `format'
 ransack (0.7.2) lib/ransack/nodes/condition.rb:193:in `block in formatted_values_for_attribute'
 ransack (0.7.2) lib/ransack/nodes/condition.rb:191:in `map'
 ransack (0.7.2) lib/ransack/nodes/condition.rb:191:in `formatted_values_for_attribute'
 ransack (0.7.2) lib/ransack/nodes/condition.rb:167:in `block in arel_predicate'
 ransack (0.7.2) lib/ransack/nodes/condition.rb:166:in `map'
 ransack (0.7.2) lib/ransack/nodes/condition.rb:166:in `arel_predicate'
 ransack (0.7.2) lib/ransack/visitor.rb:17:in `visit_Ransack_Nodes_Condition'
 ransack (0.7.2) lib/ransack/visitor.rb:60:in `visit'
 ransack (0.7.2) lib/ransack/visitor.rb:5:in `accept'
 ransack (0.7.2) lib/ransack/visitor.rb:36:in `block in visit_or'
 ransack (0.7.2) lib/ransack/visitor.rb:36:in `map'
 ransack (0.7.2) lib/ransack/visitor.rb:36:in `visit_or'
 ransack (0.7.2) lib/ransack/visitor.rb:21:in `visit_Ransack_Nodes_Grouping'
 ransack (0.7.2) lib/ransack/visitor.rb:60:in `visit'
 ransack (0.7.2) lib/ransack/visitor.rb:5:in `accept'
 ransack (0.7.2) lib/ransack/visitor.rb:25:in `block in visit_and'
 ransack (0.7.2) lib/ransack/visitor.rb:25:in `map'
 ransack (0.7.2) lib/ransack/visitor.rb:25:in `visit_and'
 ransack (0.7.2) lib/ransack/visitor.rb:21:in `visit_Ransack_Nodes_Grouping'
 ransack (0.7.2) lib/ransack/visitor.rb:60:in `visit'
 ransack (0.7.2) lib/ransack/visitor.rb:5:in `accept'
 ransack (0.7.2) lib/ransack/adapters/active_record/context.rb:30:in `evaluate'
 ransack (0.7.2) lib/ransack/search.rb:25:in `result'

If more info are needed please let me know.

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

thanks jonatack for that helpful post… here is what I came up with for this to work in mysql

ransacker :id do
  Arel.sql("substring(CAST(tablename.id as CHAR(12)),length(id))")
end