Reputation: 9666
I have an includes file with this content - @show = :dev
I need to include this file in my layout so I can use this variable everywhere. I've tried including it:
.content
= render "includes/dev_live"
but it only works if I reference it in every view rather than just once in the layout. I can't just type in the variable as my site is hosted on two servers each with different variables.
Upvotes: 0
Views: 130
Reputation: 5015
Try the rails_config gem, it allows you to create settings files that are available in all controllers/views. For example have a settings file that reads:
:show
'live'
then in your controllers/views you can access this by writing
Settings.show
(optionally converting to a symbol using to_sym if necessary) By default the rails config gem has a local settings file which is not tracked by version control (for git anyway), so you can have different versions on different instances.
Upvotes: 1