# Accessing application helper from a tag

**URL:** <https://www.ruby-forum.com/t/accessing-application-helper-from-a-tag/110602>\
**Category:** Radiant CMS\
**Created:** [July 27, 2007, 11:07pm UTC](https://www.ruby-forum.com/t/accessing-application-helper-from-a-tag/110602 "2007-07-27T23:07:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dana\_Janssen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea5d25/32.png) [@Dana\_Janssen](https://www.ruby-forum.com/u/Dana_Janssen)\
**Post date:** [July 27, 2007, 11:07pm UTC](https://www.ruby-forum.com/t/accessing-application-helper-from-a-tag/110602/1 "2007-07-27T23:07:58Z")

</div>

I’ve been subscribed to this mailing list for many months now but  
this is my first time posting. Please forgive me if I do something  
wrong 🙂

I am trying to use tags to show content based on user session &  
permissions. For example, a custom sidebar for when someone is not  
logged in, for when they are logged in as an administrator, etc.

In the radiant admin this is performed by erb in /vendor/radiant/app/  
views/layouts/application.rhtml. I could create a layout like this,  
but then I don’t have pages that are editable through radiant.

I believe the problem is that the tag I have written does not see the  
radiant application helper. Is there any way to get around this? My  
code is below with the error.

from vendor/extensions/session\_tags/app/models/session\_tags.rb:

module SessionTags  
include Radiant::Taggable

desc %{ Check for admin session. }  
tag ‘session’ do |tag|  
if admin?  
tag.expand  
end  
end

end

from vendor/radiant/app/helpers/application\_helper.rb:

def admin?  
user = session[‘user’]  
user and user.admin?  
end

in the page part:

\<r:session\>  
Put your radius tags here  
\</r:session\>

outputs:

undefined method `admin?’ for #

---

<div class="post-metadata">

**Author:** ![Dana\_Janssen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea5d25/32.png) [@Dana\_Janssen](https://www.ruby-forum.com/u/Dana_Janssen)\
**Post date:** [July 27, 2007, 11:13pm UTC](https://www.ruby-forum.com/t/accessing-application-helper-from-a-tag/110602/2 "2007-07-27T23:13:59Z")

</div>

Can you do a view source and see what the actual object type is that  
is indicated by the # in the error. Since objects are returned as  
#ObjectName:124342 they get partially mistaken for HTML tags by  
browsers rendering the page.

-James
