I have been working on a rails project on an Ubuntu environment since 2 years, and now I have shifted to Mac. My other team mate still use Ubuntu, and even the prod environment is Ubuntu. So my question is, Is there a way by which I can work on Mac and not change the Gemfile or any other project configurations so that the prod code and my team mates code is not affected because of me? And then how does heroku host a project pushed from an Ubuntu machine and a Mac, because the socket addresses given in Gemfile on both machines are different or should I use a VM on Mac?
1 Answers
The app will run in any environment, so long as you have the dependencies to get it working.
If you have Ruby
and Rails
running on your Mac box, you need to get your app's files and then try using bundle
. If the bundle works, you'll be good to go. If it doesn't, you'll have to work on installing each gem it requires until it works.
This is an acute problem with Windows -- getting the libraries / dependencies to work can be tricky. However, if the dependencies are present on the system, it should work no matter which OS you're using.
We develop with Windows, and have production apps running in Ubuntu.
--
If you wanted to change the database.yml
file, you'd have to have some sort of conditional logic to determine whether you're running on a Mac or not.
I'm not sure how you do that, but it would be very similar to using the likes of Rails.env.development?
etc:
#config/database.yml
def host
if /darwin/ ~= RUBY_PLATFORM
# MAC
elsif /linux/ ~= RUBY_PLATFORM
# Linux
end
end
development:
host: <%= host %>
You can use the RUBY_PLATFORM
constant to determine the OS

- 1
- 1

- 76,116
- 9
- 93
- 147
-
If we see **database.yml** file the socket values are different for OSX and Ubuntu, so should I do `git checkout database.yml` everytime I push code to my prod branch from OSX? – Sahil Dec 12 '15 at 10:35
-
1Well if you're not using MAC in prodution, why do you need to change the values for the production `database.yml` file? Just change your `development` settings and it will work, surely? – Richard Peck Dec 12 '15 at 10:38
-
Thanks Rich,I would have to still checkout for development as other members use Ubuntu and If I push with this change they will start getting errors on their machine. – Sahil Dec 12 '15 at 10:41
-
Yep. There are ways around this -- using conditional settings etc. I'm not sure whether you can call the operating environment, but that would help. I'll write an update – Richard Peck Dec 12 '15 at 10:47
-
Thanks a lot Rich. If you could also help me with [this question](http://stackoverflow.com/q/33936671/3863146)? I have been trying to run my old code from atleast 3 weeks or more but I am unable to. – Sahil Dec 12 '15 at 10:57