I need to pass some values from a CMS to a rails view. I should check these values are defined in the CMS. These values are meant to be use in all pages, hence the use of application_controller.rb
. As of now Im using a method to check for the existence of a favicon, but this will result in a new validation method for every field (addres, email, phone, etc…).
class ApplicationController < ActionController::Base before_action :set_constants def set_favicon if Fae::Option.instance.try(:favicon).nil? @favicon = '' else @favicon = Fae::Option.instance.favicon.asset.url end end def set_constants set_favicon @company = { address: CompanyInfo.instance.address.content, email: CompanyInfo.instance.email.content, phone: CompanyInfo.instance.phone.content, facebook_url: CompanyInfo.instance.facebook_url.content, instagram_url: CompanyInfo.instance.instagram_url.content, youtube_url: CompanyInfo.instance.youtube_url.content } end end