A method accessible from all controllers and views ? How?

Hi,

I’ve got this method :

def is_admin?
@current_user && @current_user.admin == 1
end

I want to be able to call this method from all my controllers and all my
views.
If I put this method in application_controller I can call it from all my
controllers but none of my views.
If I put this method in application_helper I can call it from all my
views but none of my controllers.

What is the best way?

Thanks.
Nicolas B…

On 21 Jan 2008, at 11:37, Nicolas B. wrote:

all my
views.
If I put this method in application_controller I can call it from
all my
controllers but none of my views.
If I put this method in application_helper I can call it from all my
views but none of my controllers.

Put it in application.rb & then use helper_method ?

Fred

put it in the User model

you can also use a mix in.

module X
def is_admin
end
end

class some_controller
include X
helper :x
end