You can access it directly like this
class PagesController < ApplicationController
@@company = "Acme" # class var
def home
@title = "Welcome to #{@@company}"
end
def faq
@title = "FAQ | #{@@company}"
end
end
Or define a custom getter method like this
class PagesController < ApplicationController
@@company = "Acme"
def home
@title = "Welcome to #{company}"
end
def faq
@title = "FAQ | #{company}"
end
private
def company
@@company
end
end
Or get Company name from database
class PagesController < ApplicationController
def home
@title = "Welcome to #{company}"
end
def faq
@title = "FAQ | #{company}"
end
private
def company
@company ||= current_user.company # get company of logged in user (and "cache" it)
@company.name
end
end