I have Post model with published? field and some authorization system which defines admin? method inside ApplicationController.
I want to restrict access to unpublished posts and show them only to administrator.
I tried to define a scope accessible to return only published posts to users, but all posts for administrator.
scope :published, where(:published => true)
def self.accessible
admin? ? all : published
end
The problem is that admin? method can't be accessed inside the model. What is the best way to implement what I want?