This project is archived and is in readonly mode.

#3633 ✓resolved
Conrad Taylor

Undefined method, 'having', for Arel gem

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

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'

Comments and changes to this ticket

  • Kieran P

    Kieran P January 1st, 2010 @ 06:52 AM

    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'
    
  • Conrad Taylor

    Conrad Taylor January 1st, 2010 @ 01:04 PM

    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.

  • Matija Folnovic

    Matija Folnovic January 1st, 2010 @ 01:45 PM

    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 ?

  • Matija Folnovic

    Matija Folnovic January 1st, 2010 @ 02:06 PM

    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

  • Conrad Taylor

    Conrad Taylor January 2nd, 2010 @ 04:24 AM

    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).

  • Matija Folnovic

    Matija Folnovic January 2nd, 2010 @ 11:14 AM

    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

  • Matija Folnovic

    Matija Folnovic January 2nd, 2010 @ 11:16 AM

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

  • Conrad Taylor

    Conrad Taylor January 2nd, 2010 @ 12:05 PM

    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.

  • Josh Graham

    Josh Graham January 6th, 2010 @ 02:33 AM

    +1 to Kieren P's suggestion.

  • Conrad Taylor

    Conrad Taylor January 8th, 2010 @ 02:31 PM

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

    Conrad Taylor January 11th, 2010 @ 02:03 AM

    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"
    
  • Steve St. Martin

    Steve St. Martin January 12th, 2010 @ 04:17 AM

    • 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.

  • Emilio Tagua

    Emilio Tagua March 12th, 2010 @ 06:54 PM

    • State changed from “new” to “resolved”

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

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages