class Post < ActiveRecord::Base
belongs_to :users
def self.find_latest_closed
Post.where("status=?",'Closed').order("updated_at DESC").limit(2)
end
def self.find_latest_open
Post.where("status=?",'Open').order("updated_at DESC").limit(2)
end
end
In PostController
class UsersController < ApplicationController
def dashboard
@totalclose = Post.find_latest_closed
@totalopen = Post.find_latest_open
end
end
I get the following error
NoMethodError in UsersController#dashboard
undefined method `find_latest_closed' for #<Class:0x000001074eb760>
Whats wrong here ?
It’s possible you’ve got some sort of conflict with ActiveRecord’s magic
find_*methods. Maybe try changing the method names toget_*.