Mac and Rails

Hello,

I have been just tasked to learn Rails for a new project and have been
given Mac machine for it. I have never used a Mac / Linux ever. I have
used Rails before on Windows. I need to set up Rails development env
on this Mac machine. Its Mac OS X - Snow Leopard. The development
environment needs Rails 2.3.5, GIT client and MySQL. We are still
swaying between using Mongreal or Apache locally, because the
production will be in Apache.

Can someone advise what the best practices, best tools, editors, etc
to set up Rails development env locally on a Mac? Apologize for the v
basic question. :slight_smile:

Regards
Vikram

I have been just tasked to learn Rails for a new project and have been

given Mac machine for it. I have never used a Mac / Linux ever. I have

used Rails before on Windows. I need to set up Rails development env

on this Mac machine. Its Mac OS X - Snow Leopard. The development

environment needs Rails 2.3.5, GIT client and MySQL. We are still

swaying between using Mongreal or Apache locally, because the

production will be in Apache.

Use Apache locally too. It’s simple, Apache is already installed on Snow Leopard. Install Passenger and configure it (which you’ll need to learn how to do for production anyway). Update your gems on Snow Leopard (as Rails is also already installed on Snow Leopard) and away you go.

Can someone advise what the best practices, best tools, editors, etc

to set up Rails development env locally on a Mac? Apologize for the v

basic question. :slight_smile:

As I said, you already have Rails and Apache ready to go. You need to install MySQL (or use sqlite in development) and that’s it. I personally use TextMate, but RubyMine looks awesome if you don’t mind the lag for Java-based IDEs to start up.

Cheers,

Andy

Homebrew (http://github.com/mxcl/homebrew) is your friend for software
dependencies installation.

Here's a rough guide that gives the process:

http://samsoff.es/posts/running-rails-local-development-with-nginx-postgres-and-passenger-with-homebrew

Substitute mysql for postgresql and drop the nginx install and most of
the steps are the same.

Personally, I use Ruby Enterprise Edition as installed from Homebrew,
too and it works well for managing RubyGems without sudo (passenger is
included in the install). It's what I use in production, so it makes
my development environment more closely match what I'm using in
production.

Cheers,
Walter

or u can use rvm with ree =)

Ivan Nastyukhin
dieinzige@me.com

There are some wonderful guides out there for this. Rails works great
out-of-the-box on OS X.

Out of the editors I've used, I believe textmate is the best. It's
visually pleasing and very extensible. It also is the text editor seen
in the famous "Rails Casts" from 37Signals. http://macromates.com/

I use Textmate in combination with Panic's Transmit ftp software
(http://www.panic.com/transmit/) and Firefox armed with Firebug as my
environment. I find it highly productive. (I love textmate and it
seems to be one of the posterchild editors for Rails, but it will take
some time to get used to. It has a lot of great features)

You have a few options for your Rails installation...

The absolute easiest is just to update the Rails app installed with OS
X. You'll be up and running in just a few minutes:
http://wiki.rubyonrails.org/getting-started/installation/mac

If you don't want that, consider the RubyStack from BitNami:
http://bitnami.org/stack/rubystack

For maximum control, you can manually build Rails, as well:
http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard

Lastly, I've not needed to use a particular version of Rails so far,
but I believe you can install older versions of rails as Gems, if you
need them. See this article: http://www.nomachetejuggling.com/2008/03/12/using-multiple-versions-of-rails/

Hope that helps a little.

Andy Jeffries wrote:

I have been just tasked to learn Rails for a new project and have been
given Mac machine for it. I have never used a Mac / Linux ever. I have
used Rails before on Windows. I need to set up Rails development env
on this Mac machine. Its Mac OS X - Snow Leopard. The development
environment needs Rails 2.3.5, GIT client and MySQL. We are still
swaying between using Mongreal or Apache locally, because the
production will be in Apache.

Use Apache locally too. It's simple, Apache is already installed on
Snow
Leopard. Install Passenger and configure it (which you'll need to learn
how
to do for production anyway).

What a waste of effort IMHO. I've never used anything but Mongrel
locally. It works fine n

Update your gems on Snow Leopard (as
Rails is
also already installed on Snow Leopard) and away you go.

Can someone advise what the best practices, best tools, editors, etc
to set up Rails development env locally on a Mac? Apologize for the v
basic question. :slight_smile:

As I said, you already have Rails and Apache ready to go. You need to
install MySQL (or use sqlite in development) and that's it. I
personally
use TextMate, but RubyMine looks awesome if you don't mind the lag for
Java-based IDEs to start up.

Please don't bother with an IDE for Rails; it doesn't need or want one.
KomodoEdit rocks.

Check out http://www.apple.com/support/switch101 . Consider iTerm as a
more powerful substitute for Terminal.app . If you're using Git, get
GitX.

Best,

Use Apache locally too. It’s simple, Apache is already installed on

Snow

Leopard. Install Passenger and configure it (which you’ll need to learn

how

to do for production anyway).

What a waste of effort IMHO. I’ve never used anything but Mongrel

locally. It works fine n

What effort? It’s 4 lines of typing to get Passenger installed:

gem install passenger

passenger-install-apache2-module
(copy the suggested lines and paste into…)

mate /etc/apache2/httpd.conf

sudo apachectl restart

Download the Passenger Preferences Pane (http://github.com/alloy/passengerpane/downloads) to be able to set up new sites easily using a GUI. Much easier than setting up Mongrel as a daemon to serve multiple sites in the background.

How do you set up Mongrel that’s easier (from scratch) than the above? I’m assuming you’re not just working on a single Rails site and just do “rails s” or “script/server” when you need it up (I have locally running websites available all the time).

Cheers,

Andy

Andy Jeffries wrote:

> Use Apache locally too. It's simple, Apache is already installed on
> Snow
> Leopard. Install Passenger and configure it (which you'll need to learn
> how
> to do for production anyway).

What a waste of effort IMHO. I've never used anything but Mongrel
locally. It works fine n

What effort? It's 4 lines of typing to get Passenger installed:

gem install passenger
passenger-install-apache2-module
(copy the suggested lines and paste into...)
mate /etc/apache2/httpd.conf
sudo apachectl restart

Yes, but "script/server -u" is even easier. I love Passenger on
servers, but there's no advantage to using it on a dev machine.

Download the Passenger Preferences Pane (
http://github.com/alloy/passengerpane/downloads) to be able to set up
new
sites easily using a GUI. Much easier than setting up Mongrel as a
daemon
to serve multiple sites in the background.

How do you set up Mongrel that's easier (from scratch) than the above?
I'm
assuming you're not just working on a single Rails site and just do
"rails
s" or "script/server" when you need it up (I have locally running
websites
available all the time).

I don't see the point of that on a development machine either. I can't
imagine a use case in which I'd need multiple Rails sites running
simultaneously on my development machine. I just type script/server for
whatever project I'm working on at a given time.

Cheers,

Andy

Best,

Marnen Laibow-Koser wrote:

How do you set up Mongrel that's easier (from scratch) than the above?
I'm
assuming you're not just working on a single Rails site and just do
"rails
s" or "script/server" when you need it up (I have locally running
websites
available all the time).

I don't see the point of that on a development machine either. I can't
imagine a use case in which I'd need multiple Rails sites running
simultaneously on my development machine. I just type script/server for
whatever project I'm working on at a given time.

I have to agree with Marnen on this point. I don't run services on my
machines that are unnecessary. I don't have Apache running all the time.
It's not like I server web sites from my laptop. I don't run MySQL on my
development box all the time. I don't develop multiple-sites
concurrently, so I see no point in having them running all the time.

I'm quite happy with ./script/server, which I aliased as 'ss' in my
profile so I just type ss in my already running terminal window and my
site it up and running with Mongrel. And, given that Mongrel is
pre-installed by Apple, there's nothing to install, keeping my
development machine just that much cleaner.

P.S. +1 to whoever mentioned Homebrew. Finally an alternative to
macports that I can be happy with. self => "macports hater"

P.S. +1 to whoever mentioned Homebrew. Finally an alternative to
macports that I can be happy with. self => "macports hater"

Really, what's the deal about macports? I find it works quite well. What
problems does homebrew solve?

Fernando Perez wrote:

P.S. +1 to whoever mentioned Homebrew. Finally an alternative to
macports that I can be happy with. self => "macports hater"

Really, what's the deal about macports? I find it works quite well. What
problems does homebrew solve?

Yeah. I don't much like MacPorts either, but Fink seems like a better
alternative than Homebrew (though I can imagine that changing at some
point). The enthusiasm for Homebrew seems more like "ZOMG it's
Ruby!!!11!!one!" than anything else, unless I'm missing something.

Best,

You are missing something. Both Fink and MacPorts push the user
towards using an alternative directory structure (/sw for Fink, /opt)
rather than use /usr/local. Some people like this alternative path
structure as it can be easy to clean out, etc.

However, using either, when a package wasn't available, I often would
build from source under /usr/local and end up with two directory
structures, one for packages and one built from source. A pain.

Both systems required mucking with you PATH, etc. to maintain this
alternative software repository.

Both systems are ports of other platforms' (Fink is Debian apt style,
MacPorts is FreeBSD ports style) software packaging systems and don't
feel quite right on a Mac to me. Homebrew was a fresh approach to the
problem that also is a simplification and realizes the existing intent
of /usr/local in the *nix architecture. As such it also realizes
that sudo/root to install packages is usually unnecessary and is not a
beneficial idiom.

I preferred MacPorts over Fink for a long time. My biggest gripe with
it was that packages were way behind the times. The community wasn't
there. Homebrew's biggest advantage is probably that it is very easy
to submit/update a package for a software library via being on github.
Fork, update Homebrew, pull request, and you are done. Use your fork
instead of the canonical Homebrew repository if you have custom needs,
etc.

The easiness of getting the pieces of software you need into the
system via Github makes the system stay grow rabidly and also keeps it
fresh.

Cheers,
Walter