I am trying to upgrate rails from 3.0 to 3.1, while updating rails version 
I am getting following error

rake aborted!
undefined method `sanitize_limit' for 
#<ActiveRecord::Relation:0x2aaaad35d720>
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation.rb:460:in
 
`method_missing'
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/query_methods.rb:208:in
 
`build_arel'
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/query_methods.rb:196:in
 
`arel'
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation.rb:112:in
 
`to_a'
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/finder_methods.rb:376:in
 
`find_first'
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/finder_methods.rb:122:in
 
`first'

Error is occurred at the execution of following statement:
test = where(search_column_name => attributes[search_column_name]).first

I found following solution on internet:
https://github.com/rails/rails/issues/1974

Hence updated to:
test = where(search_column_name => 
attributes[search_column_name]).all.to_a.first

...and this statement started working fine.

But, find_by_name() is still failing with the same error.
for eg. the below statement is not always working.
test_lookup = find_by_identifier(lookup_str) || find_by_name(lookup_str) || 
find_by_abbreviation(lookup_str)

statement is called under a function, defined in a model:
def self.lookup(lookup_str)
  return nil if lookup_str.blank?
  test_lookup = find_by_identifier(lookup_str) || find_by_name(lookup_str) 
|| find_by_abbreviation(lookup_str)
  return test_lookup if test_lookup.present?
end

It throws following error:
rake aborted!
undefined method `sanitize_limit' for 
#<ActiveRecord::Relation:0x2aaaacf14010>
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation.rb:460:in
 
`method_missing'
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/query_methods.rb:208:in
 
`build_arel'
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/query_methods.rb:196:in
 
`arel'
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation.rb:112:in
 
`to_a'
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/finder_methods.rb:376:in
 
`find_first'
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/finder_methods.rb:122:in
 
`first'
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/finder_methods.rb:263:in
 
`send'
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/finder_methods.rb:263:in
 
`find_by_attributes'
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/base.rb:1074:in
 
`send'
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/base.rb:1074:in
 
`method_missing'

What should be the alternative for find_by_name() [i.e. 
find_by_attribute()]???

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to