Sutto / rocket_pants

API building tools on top of ActionController. Also, an awesome name.
MIT License
981 stars 130 forks source link

Forced to require 'will_paginate' in environment.rb #60

Closed adg29 closed 11 years ago

adg29 commented 11 years ago

If I don't require 'will_paginate' in my environment.rb file I get the following error:

undefined method `paginate' for #<ActiveRecord::Relation:0x007fd832b6e5b0>

Wanted to point this out and perhaps find some explanation for this.

Perhaps this is due to my application setup? Perhaps you will see if the issue stems from my Gemfile.lock (notice will_paginate is listed twice)? Let me know if you observe anything:

$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin12.2.0]
$ rails -v
Rails 3.2.11
$ bundle -v
Bundler version 1.2.3

This is the use case between the model and controller for the my resource

class Product < ActiveRecord::Base
  include RocketPants::Cacheable
  ...
end

class Api::ProductsController < RocketPants::Base
  version 1
  ...

def search
    ...
    expose Product.where("vendor_cats like ?", q).paginate(:page => params[:page])
end

And here is the relevant part of my Gemfile.lock

    rocket_pants (1.7.0)
      actionpack (>= 3.0, < 5.0)
      api_smith
      hashie (~> 1.0)
      moneta
      railties (>= 3.0, < 5.0)
      will_paginate (~> 3.0)
    sass (3.2.5)
    sass-rails (3.2.6)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    seedbank (0.2.0)
    simple_form (2.0.4)
      actionpack (~> 3.0)
      activemodel (~> 3.0)
    simple_oauth (0.1.9)
    sprockets (2.2.2)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    thor (0.17.0)
    tilt (1.3.3)
    treetop (1.4.12)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.35)
    uglifier (1.3.0)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)
    warden (1.2.1)
      rack (>= 1.0)
    weary (1.1.2)
      addressable (~> 2.3.2)
      multi_json (~> 1.3.0)
      promise (~> 0.3.0)
      rack (~> 1.4.0)
      simple_oauth (~> 0.1.5)
    will_paginate (3.0.4)

PLATFORMS
  ruby

DEPENDENCIES
  bootstrap-sass (~> 2.2.2.0)
  coffee-rails (~> 3.2.1)
  devise
  gilt
  high_voltage
  httparty
  ice_cube
  jquery-rails
  localtunnel
  multi_json (~> 1.3.0)
  omniauth-singly
  omniauth-twitter
  pg
  rails (= 3.2.11)
  rocket_pants
  sass-rails (~> 3.2.3)
  seedbank
  simple_form
  uglifier (>= 1.0.3)
Sutto commented 11 years ago

Hey there,

We depend on will paginate but since we only use the collection class, we leave the rest of it as is. What do you have in your Gemfile for will_paginate? It looks like nothing directly, so if that's the case I suggest explicitly adding it there (which should also have the effect of loading it for you)

Sutto commented 11 years ago

Closing since I haven't head back wrt to the comment above. Let me know and I'll reopen if you still have issues.