Copying controller methods to helpers.

Jake Janovetz
Sun, 21 Jan 2007 06:41:53 -0000

I have a case where replicas of certain controller methods would be
useful within the view.  In particular, these are role-based user-access
methods.

For example:
   can_view?
   can_modify?

These will be methods setup in the AccountSystem module which is
included in the ApplicationController.  These methods will be used as
before_filters to determine if the user has access to do a certain thing
or not.

I would also like to provide these same methods to my views, but I
don''t
quite understand how the scope will work.

My views don''t have access to the "can_view?" from
AccountSystem.  But
if I put a can_view? method in a helper, how would it call the can_view?
from AccountSystem?

Also, would there be a simple way to duplicate these in one fell-swoop
to get all the methods copied over?

   Jake

--
Posted via http://www.ruby-forum.com/.