Tanmay Baid
2013-Mar-28 10:50 UTC
undefined method ''sanitize_limit'' for #<ActiveRecord::Relation:0x2aaaad35d720>
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+unsubscribe@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.
Richard Schneeman
2013-Mar-28 22:43 UTC
Re: undefined method ''sanitize_limit'' for #<ActiveRecord::Relation:0x2aaaad35d720>
This list is reserved for discussion of the upcoming release of Rails and it''s contributors. For general bugs and questions please ask this question on stack overflow or post to https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-talk -- Richard Schneeman http://heroku.com @schneems (http://twitter.com/schneems) On Thursday, March 28, 2013 at 5:50 AM, Tanmay Baid wrote:> 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+unsubscribe@googlegroups.com (mailto:rubyonrails-core+unsubscribe@googlegroups.com). > To post to this group, send email to rubyonrails-core@googlegroups.com (mailto: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. > >-- 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+unsubscribe@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.
Maybe Matching Threads
- how to yum install after deleting some files?
- Building a newer glibc RPM for CentOS 6 and installing into an alternate path
- yum: removing Java group fails
- Installing Ruby gems on RPM-based systems
- Building a newer glibc RPM for CentOS 6 and installing into an alternate path