Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Undefined method, 'having', for Arel gem

#3633

I'm seeing the following issue after creating a very simple site using Rails 3.0.pre


NoMethodError (undefined method `having' for #<Arel::Project:0x33954d4>):
  /opt/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/relation.rb:70:in `having'
  /opt/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/base.rb:1565:in `construct_finder_arel'
  /opt/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/base.rb:1585:in `construct_finder_arel_with_includes'
  /opt/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/base.rb:649:in `find'
  /opt/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/base.rb:676:in `all'
  app/controllers/posts_controller.rb:5:in `index'

Reported by Conrad Taylor · December 30th, 2009 @ 10:42 AM

State: resolved
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Kieran P
    Kieran P

    My understanding is that the Arel gem isn't released yet, which contains the latest changes. You will need to put this in your Gemfile and rebundle:

    gem 'arel', :git => 'git://github.com/rails/arel.git'
    

    January 1st, 2010 @ 06:52 AM

  2. Conrad Taylor
    Conrad Taylor

    This issue has been resolved by updating the submodules, git submodule update, which was the missing piece of the puzzle. Then performing a git pull followed by a sudo rake install. Things are back to normal.

    @Kieran P - Thanks for the information because your information gave me the idea to revisit Rails 3.0.pre installation.

    January 1st, 2010 @ 01:04 PM

  3. Matija Folnovic
    Matija Folnovic

    I'm having same problem...

    Conrad: tried your way, and I also tried to remove arel and init+update it again, and then sudo rake install, but still getting same error

    Kleran: I don't understand your way, in which Gemfile should I put that and what do I do next ?

    January 1st, 2010 @ 01:45 PM

  4. Matija Folnovic
    Matija Folnovic

    Conrad: ok, fixed it somehow, I had to do: git clone git://github.com/rails/arel.git instead of doying git submodule update since this didn't give me latest code:

    Submodule path 'arel': checked out '0faeb5047407348533db952d9cf93ea59d2526dc'
    but newest commit is: c836c3ed10110d0446c4fce87d36c3f6c39b3cda

    January 1st, 2010 @ 02:06 PM

  5. Conrad Taylor
    Conrad Taylor

    Matija, my previous instructions were not correct. One would need to perform the operations in the following order instead:

    
    git pull
    git submodule update
    sudo rake install
    

    In short, one will need to update the master project (i.e. rails) before updating any of its submodules (i.e. rack and arel).

    January 2nd, 2010 @ 04:24 AM

  6. Matija Folnovic
    Matija Folnovic

    just tried that too, and still ( tried first without first two steps, and same thing ):

    mfolnovic@mfolnovic-laptop:/media/Elements/mfolnovic/Projects/rails$ rm -r arel
    mfolnovic@mfolnovic-laptop:/media/Elements/mfolnovic/Projects/rails$ git submodule init
    mfolnovic@mfolnovic-laptop:/media/Elements/mfolnovic/Projects/rails$ git submodule update
    Initialized empty Git repository in /media/Elements/mfolnovic/Projects/rails/arel/.git/
    remote: Counting objects: 4968, done.
    remote: Compressing objects: 100% (1882/1882), done.
    remote: Total 4968 (delta 3092), reused 4604 (delta 2879)
    Receiving objects: 100% (4968/4968), 517.32 KiB | 288 KiB/s, done.
    Resolving deltas: 100% (3092/3092), done.
    Submodule path 'arel': checked out '0faeb5047407348533db952d9cf93ea59d2526dc'
    

    but deleting and cloning from repo gets me to correct commit :P

    January 2nd, 2010 @ 11:14 AM

  7. Matija Folnovic
    Matija Folnovic

    and I also did git pull before all this... ( argh, why I can't edit my comments :S )

    January 2nd, 2010 @ 11:16 AM

  8. Conrad Taylor
    Conrad Taylor

    Matija, after removing the entire rails repository and re-installing everything, my initial still exists. It appears that AR is attempting to call a Arel method, 'having', which doesn't exist:

    
    /opt/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/relation/query_methods.rb:39:in `having'
    

    The extract of the method contains the following:

    
        def having(*args)
          return spawn if args.blank?
    
          if [String, Hash, Array].include?(args.first.class)
            havings = @klass.send(:merge_conditions, args.size > 1 ? Array.wrap(args) : args.first)
          else
            havings = args.first
          end
    
          spawn(@relation.having(havings))  # NoMethodError (undefined method `having' for #<Arel::Project:0x2da4bc8>)
        end
    

    Next, the 'git pull' of the parent project, rails, is associated with a certain commit of arel and a certain commit of rack. Thus, after comparing the sha1 hash on github.com with the sha1 hash on my system for the arel project, I would say that I have the latest
    source.

    January 2nd, 2010 @ 12:05 PM

  9. Josh Graham
    Josh Graham

    +1 to Kieren P's suggestion.

    January 6th, 2010 @ 02:33 AM

  10. Conrad Taylor
    Conrad Taylor
    • Tag changed from arel, rails3 to arel, rails3, ruby1.9

    January 8th, 2010 @ 02:31 PM

  11. Conrad Taylor
    Conrad Taylor

    After updating my Gemfile, it seems that things are finally working again. You can find my Gemfile below:

    # Edit this Gemfile to bundle your application's dependencies.
    
    git "git://github.com/rails/arel.git"
    
    ## Bundle edge rails:
    gem "rails", "3.0.pre", :git => "git://github.com/rails/rails.git"
    
    ## Bundle the gems you use:
    gem "sqlite3-ruby", :require_as => "sqlite3"
    gem "rack"
    gem "tzinfo"
    

    January 11th, 2010 @ 02:03 AM

  12. Steve St. Martin
    Steve St. Martin
    • Tag changed from arel, rails3, ruby1.9 to arel, invalid, rails3, ruby1.9

    I was able to successfully create a working rails app with the above Gemfile, seems issues are only encountered when using directory within your Gemfile and pointing it at the initial clone.

    January 12th, 2010 @ 04:17 AM

  13. Emilio Tagua
    Emilio Tagua
    • State changed from new to resolved

    This was a problem in Arel release not including having, this issue is already solved.

    March 12th, 2010 @ 06:54 PM