I'm trying to set up two environments for my site, one on a development server, one on a live one. And I want to dictate which records from the DB can be seen on each server. I've created a file in my includes, for development it has this @show = "dev" and for live it has @show = "live" I've included this at the top of my application layout so it is on every page. Then in my views, with each database call I want to put some conditions like this:
- f = Event.find(:all, :conditions => ["#{@show} = 1"])
But it doesn't pick up @show as being the variable, just uses it explicitly or ignores it. Is there a simple way to do this or will this not work how I expect it to?
update
I've managed to make it work, but I have to include the file on each individual view rather than just on the application layout... Not ideal but it's a solution:
= render "includes/dev_live"
- f = Event.find(:all, :conditions => {@show => 1})
Rails.env) rather than your own global variable.