Accessing controller variable from view


#1

In my ApplicatoinController I have:

class ApplicationController < ActionController::Base

MOBILE_USER_AGENTS = ‘palm|palmos|palmsource|iphone|blackberry|
nokia|phone|midp|mobi|pda|’ +
‘wap|java|nokia|hand|symbian|chtml|wml|
ericsson|lg|audiovox|motorola|’ +
‘samsung|sanyo|sharp|telit|tsm|mobile|mini|
windows ce|smartphone|’ +
‘240x320|320x320|mobileexplorer|j2me|sgh|
portable|sprint|vodafone|’ +
‘docomo|kddi|softbank|pdxgw|j-phone|astel|
minimo|plucker|netfront|’ +
‘xiino|mot-v|mot-e|portalmmm|sagem|sie-s|
sie-m|android|ipod’

def is_mobile_device?
request.user_agent.to_s.downcase =~ Regexp.new
(MOBILE_USER_AGENTS)
end

My problem is in my /views/layouts/application.html.erb I have:

<% if is_mobile_device? %>

I get:

undefined method `is_mobile_device?’ for #ActionView::Base:0x6752ff0

How can I refer to is_mobile_device? from this view – as well as all
views and controllers – I want to be DRY about this - how can I do
that? -Janna B.


#2

On Jun 9, 4:04 pm, JannaB removed_email_address@domain.invalid wrote:

How can I refer to is_mobile_device? from this view – as well as all
views and controllers – I want to be DRY about this - how can I do
that? -Janna B.

Lookup helper_method

Fred