heartcombo/has_scope

Routing error with has_scope

bnussey opened this issue · 2 comments

I am getting the error below with has_scope. This seems like a really obvious and basic error but I just can't work it out. I'd really appreciate any help that can be offered.

I have got ActiveAdmin elsewhere on the site and I believe that uses it so we can assume the gem is operating correctly.

I've checked the gem is installed and it is has_scope (0.6.0.rc)

ActionController::RoutingError at /products
undefined method `has_scope' for ProductsController:Class

Model:

class Product < ActiveRecord::Base
    belongs_to :category

# Scopes
default_scope { order('end_date DESC') } 
scope :upward_trending, -> { where( "status > ?", 100).order('end_date DESC') }
end

Controller:

class ProductsController < ApplicationController
    before_filter :authenticate_user!

has_scope :upward_trending

def product_params
    params.require(:product).permit(:name, :status)
end

def index
    @q = Product.search(params[:q])
    @products = apply_scopes(@q.result.page(params[:page]).per(5)).all
end


def show
end

end

Routes:

resources :products, only: [:index]

Just wondering: have you restarted your server after installing the gems and stuff?

Which Rails version are you using? Can you try on a new app and see if it works? Thanks.

Hey @carlosantoniodasilva thanks for your reply.

I have indeed restarted the server. I beieve the gem was installed along with ActiveAdmin and I am able to select scopes as filters in there without issue.

I am using Rails 4.1.0

I can look into doing a new app, unless there is something obvious that you think I might have missed?