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
在 PostController 中
class UsersController < ApplicationController
def dashboard
@totalclose = Post.find_latest_closed
@totalopen = Post.find_latest_open
end
end
我收到以下错误
NoMethodError in UsersController#dashboard
undefined method `find_latest_closed' for #<Class:0x000001074eb760>
这里有什么问题?