mardi 14 février 2017

NoMethodError in Controller#index

I am keeps on getting NoMethodError in controller index even the method is present in the model . Following is my model and controller . Please help me out where i am getting things wrong.

Controller:

    def index
      @ratings = Clerk::Rating.search(params).paginate(:per_page => 10, :page => params[:page])
    end

Model:

module Clerk
  class Rating < Base
    # Relationships
    belongs_to :application
    belongs_to :consumer

    def self.search(params)
       ratings = all
     if params[:search].present?
       ratings = ratings.joins(:consumer).where('phone like ? or lower(email) like ? or lower(first_name) like ? or lower(last_name) like ?',"%#{params[:search]}%","%#{params[:search].downcase}%","%#{params[:search].downcase}%","%#{params[:search].downcase}%")
     end
       ratings
    end
  end
end

Aucun commentaire:

Enregistrer un commentaire