I'm creating two related Rails applications, and I'm noticing a lot of non-DRY work.
For example, the @title
field being set in the various controller methods do the same thing, except for the application title, as in:
# SiteController (application 'Abc')
def SiteController < ApplicationController
def index
@title = 'Abc'
end
def about
@title = 'about Abc'
end
def news
@title = 'Abc news'
end
def contact
@title = 'contact Abc'
end
end
and:
# SiteController (application 'Xyz')
def SiteController < ApplicationController
def index
@title = 'Xyz'
end
def about
@title = 'about Xyz'
end
def news
@title = 'Xyz news'
end
def contact
@title = 'contact Xyz'
end
end
What I'm looking to do is have something like
# SiteController
def SiteController < ApplicationController
def index
@title = "#{ApplicationTitle}'
end
def about
@title = "about #{ApplicationTitle}"
end
def news
@title = "#{ApplicationTitle} news"
end
def contact
@title = "contact #{ApplicationTitle}"
end
end
The thing I'm trying to figure is: where should non-changing application settings be defined. Is it in a config/*rb file? Is it in one of the .yaml files?
Thanks in advance