Blog

Sep
18

Using passenger to run your rails applications when developing

Posted by Michael Cindric in development, mac osx, passenger, ruby on rails | No Comments »

If your like me and sick of having to run ./script/server every time you want to start your rails app using passenger locally is for you then. First thing is to install passenger like so

sudo gem install passenger

Then you need to install the apache module for passenger.

sudo passenger-install-apache2-module

Now once you do this you will be told to all the following lines to your httpd.conf file in apache. Now you can just add these lines no problems but l like to have it in its own conf file and since apache will also load all conf files in /etc/apache2/other/ directory just create a passenger.conf file and add those lines in. Now these lines are different depending on how you installed ruby. I installed it in user/local keeping the orginal ruby version that ships with mac clean so mine looks like so

LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.5
PassengerRuby /usr/local/bin/ruby

To create the new passenger.conf file just run the below command assuming you have textmate installed.

mate /etc/apache2/other/passenger.conf

Once you have cut and pasted those lines in save it and close the file. You then need to download the passenger preference pane. Here is a link to the latest build passenger-preference-pane1.3. Download and install then fire it up.

Passenger preference pane

Now unlock it if need be and click on the + button to add a new site. A window will pop up and now just select the root of your rails app and click “open”. You can now change the address if need be but just defaults to (rails_app_name).local. Hit apply and your good to go.

So go back to your browser and type in that address and it will fire up and your up and running. Now you wont see the log like you are used to since your not running webrick etc but all you have to do is tail the development log by going to the root dir of your application in terminal and typing the following

 tail -f log/development.log

And that’s it. You will need to restart passenger if you change the environment.rb file but thats simple enough via the preference pane. So no more ./script/server yay

Sep
15

no such file to load — capistrano/ext/multistage

Posted by Michael Cindric in development, mac osx, ruby on rails | No Comments »

I ran into this error the other day when running “cap -T”

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’: no such file to load — capistrano/ext/multistage (LoadError)

So to fix this l did the following

sudo gem uninstall capistrano
sudo rm -rf /usr/bin/cap
sudo gem install capistrano-ext
sudo gem install capistrano

Needed to do “sudo rm -rf /usr/bin/cap” as doing just the uninstall of capistrano didn’t remove all the files l needed it to.

Jun
15

Cool colours and GitHub branch in Terminal

Posted by Michael Cindric in development, mac osx | No Comments »

There are many posts out there about making terminal have nice colours and getting it to display your projects GitHub branch. So l thought l would post mine

Here is what my terminal looks like.

my terminal

Yes l am using Ryan Bates railscasts as my sample project (Thanks Ryan). As you can see it has the username@machine and then if you are in a project running git is also has the branch.

All you need to do it add the following to either your bash_login or bash_profile depending on what you are using. So first you run

   mate ~/.bash_login

I am using textmate to edit this file. Once there simple add the following

export CLICOLOR=1
export TERM=xterm-color
export LSCOLORS=gxfxcxdxbxegedabagacad  # cyan directories
export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ \`ruby -e \"print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"\`\[\033[37m\]$\[\033[00m\] "

Save the file and reload your bash like so and you are good to go enjoy.

  . ~/.bash_login

Of course you can change the colour of the font but ill leave that to you

Jun
05

“Open in TextMate” from Leopard Finder

Posted by Michael Cindric in development, mac osx, open source, plugins | No Comments »

Henrik Nyh has written a great little plugin that allows you to open files in TextMate from finder. Now most developers are used to doing this via terminal but this is very helpful so check it out

So click here to view the Open in Textmate button.

Mar
17

Rails 2.3 is out

Posted by Michael Cindric in development, mac osx, ruby on rails | 1 Comment »

Finally Rails 2.3 is out. Officially its tagged as 2.3.2 from memory. So what are you waiting for update already. Just run the following command in your terminal and your on your way. Sorry windows users find your own way

 sudo gem install rails

Check out the release notes here

Mar
11

Moving to anywhere on a line in terminal on Mac OSX

Posted by Michael Cindric in mac osx | No Comments »

If your like me and use terminal on you mac you might find yourself wanting to move to a point on the line you just typed. Well there is a simple way that l know at least. Just press and hold the “Option” key and click your mouse anywhere on the line and your cursor will move there.

I know there might be a better way without going back to the evil mouse but, l just don’t know it.