Tuesday, May 31, 2011

Could not find nokogiri-1.4.4 in any of the sources on Ubuntu

If you get the error: "Could not find nokogiri-1.4.4 in any of the
sources" it is probably related to "libxm12" missing. In fact, that
library is probably there. What you are missing is the development
version:

sudo apt-get install libxml2-dev

nokogiri should then install.

Reference: Manual Install

Sunday, May 22, 2011

Forcing DNS changes to take effect on Snow Leopard

I made a mistake while setting up the DNS on Linode. In order to flush the old DNS server settings. I had to run:

dscacheutil -flushcache

Then create a new zone with the right IP Address. Just ping the hostname to find the IP Address and check if it is correct by comparing it to the Linode dashboard.

Wednesday, May 11, 2011

How to highlight tabs in Rails

1) Include the following method in application helper.

def is_active?(page_name)
# logger.info("lllllllllllll #{page_name}")
# logger.info("cccccccccccccc #{params[:controller]}")
"current" if params[:controller] == page_name
end

2) In your layout, add this:

<%= link_to 'Articles', new_article_path, :class => is_active?("articles") %>


3) Uncomment the logger lines to see which controller is handling the request and just fill in
the parameters for is_active? method

Fixed an error from the code I found from an original post in Stackoverflow.

Thursday, May 05, 2011

Installing Postgres on Snow Leopard

1) sudo port install postgresql83 postgresql83-server
2)

sudo mkdir -p /opt/local/var/db/postgresql83/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql83/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql83/bin/initdb -D /opt/local/var/db/postgresql83/defaultdb'

3) sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql83-server.plist

4) sudo su postgres -c '/opt/local/lib/postgresql83/bin/postgres -D /opt/local/var/db/postgresql83/defaultdb'

5) sudo vi /etc/profile

6) Add : PATH="/opt/local/bin:/opt/local/sbin:/opt/local/lib/postgresql83/bin:$PATH"

7) createuser --superuser your_macusername -U postgres

8) createdb my_database

9) sudo env ARCHFLAGS="-arch x86_64" gem install pg

10) database.yml
development:
adapter: postgresql
database: your_db
username: your_db_username

Installing pgAdmin

sudo port install pgAdmin3

Upon completion of installation, you can find the application in /Applications/MacPorts/pgAdmin3


Reference:
Installing PostgreSQL on Snow Leopard 10.6


Installing PostgreSQL on Leopard using MacPorts