Jan23

huh, the title quite long isn’t it ?, yeah that’s because there’s a lot of options how to make postgresql working in Mac OSX environment (i’m used Mac OSX 10.5.8), the most common and easy way to install it is via macports, sadly i wasn’t going into that way,because my Apache + PHP installation came from MAMP, not macports, and also my postgresql installation came from EnterpriseDB. yeah install using this way would be pain in the ass, but only complaining wouldn’t solve something, so let’s start doing something real

1. Ruby + Rubygems

i assume you already have ruby installed, below is my configurations

aditmac:~ adit$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9]
aditmac:~ adit$ gem -v
1.3.3

so at least you need to install ruby 1.8.x or rubygems 1.3.x

2. Install MAMP + EnterpriseDB Postgresql

download MAMP at here
download EnterpriseDB Postgresql at here
install DMG is easy, so i don’t need to explain how to do that :)

3. Install and config phpPgAdmin

download phpPgAdmin at here
extract the file, copy phpPgAdmin onto htdocs directory on MAMP installation

cp -R Downloads/phpPgAdmin-4.2.2 /Applications/MAMP/htdocs/
cd /Applications/MAMP/htdocs
mv phpPgAdmin-4.2.2 phpPgAdmin

edit phpPgAdmin configurations, file is located at /Applications/MAMP/htdocs/phpPgAdmin/conf/config.inc.php

set $conf[’extra_login_security’] to false
set $conf[’owned_only’] to true

please keep in mind, this configurations should be APPLIED for localhost or development environment only, don’t use this configs for production environment because it’s very less secure

access phpPgAdmin

make sure your PostgreSql daemon is running, in finder, just click Applications/PostgreSql 8.4/Start Server
make sure your Apache daemon is running, you can start it via MAMP control panel
go to http://localhost/phpPgAdmin/, you can login using postgres username

4. Install postgres rubygems

add postgres path onto your environment variable

go to your home diretory and edit .profile file
add “/Library/PostgreSQL/8.4/bin” onto export PATH

example of my .profile file looks like this

export PATH=/usr/bin:/opt/local/bin:/opt/local/sbin:/Library/PostgreSQL/8.4/bin:$PATH
export SVN_EDITOR=/usr/bin/nano
# Finished adapting your PATH environment variable for use with MacPorts.

export MANPATH=/opt/local/share/man:$MANPATH
# Finished adapting your MANPATH environment variable for use with MacPorts.

# Setting PATH for MacPython 2.6
# The orginal version is saved in .profile.pysave
PATH=”/Library/Frameworks/Python.framework/Versions/2.6/bin:${PATH}”
export PATH

reload your profile, assume you are on your home directory, execute this

. ./.profile
echo $PATH

install postgres rubygems

sudo gem install postgres

5. Check whether postgres rubygems works well alongside Ruby on Rails
create dummy rails app

rails dummy

edit dummy/config/database.yml, it should looks like this

development:
  adapter: postgresql
  database: dummy_development
  username: postgres
  password: some_password
	
test:
  adapter: postgresql
  database: dummy_test
  username: postgres
  password: some_password
	
production:
  adapter: postgresql
  database: dummy_production
  username: postgres
  password: some_password

in your RAILS_ROOT, execute

rake db:create:all

go to your phpPgAdmin,and if you see something like this

congratz, it means your installation was succeed

Aug17

Ini sebagai dokumentasi aja, seringkali saya lupa cara meng-ignore direktori log supaya jangan sampai ter-commit ke SVN repositori, so ini caranya

Buka console, masuk ke directory RAILS_ROOT lalu ketik

svn propedit svn:ignore log/

setelah itu SVN akan memanggil editor, kalo editor tidak terpanggil dan muncul error, jangan lupa untuk ngeset SVN_EDITOR environment variable

di editor masukan semua file log yang akan di-ignore

development.log
production.log
server.log
test.log

lalu keluar dan jangan lupa di-save, setelah itu hapus file log tersebut dari SVN repositori

svn rm log/*

setelah itu silahkan perubahan yang ada di-commit

svn ci -m “ignore files inside log directory”

May07

We all know, Action Web Service (aws) no longer included in Rails 2, this makes me little bit frustation to integrate latest aws (1.2.6) to rails 2, that gems always make rails broken and raise error like this when we start the server

/usr/lib/ruby/gems/1.8/rubygems.rb:142:in `activate’: can’t activate actionpack (= 1.13.6, runtime), already activated actionpack-2.2.2 (Gem::Exception)

However, how fortunate me, Achmad Gozali, friend of mine in id-ruby suggested to used this modified aws in github and finally after i tried, my installation was succeed, so here the step

add github to your gem sources

gem sources -a http://gems.github.com/

install datanoise-actionwebservice gems, i use rails 2.2.2, so i should install datanoise-actionwebservice version 2.2.2 as well

gem install datanoise-actionwebservice -v=’2.2.2′

add this line to your config/environtment.rb (inside “Rails::Initializer.run do |config|” block)

config.gem ‘datanoise-actionwebservice’, :lib => ‘actionwebservice’, :version => ‘2.2.2′

try to start your web server, if it isn’t broken, that means your gems was successfully installed

ruby script/start

also you can make the basic code through generation

[aditya@aditya trunk]$ ruby script/generate web_service blabla
exists app/services/
exists app/controllers/
exists test/functional/
create app/services/blabla_api.rb
create app/controllers/blabla_controller.rb
create test/functional/blabla_api_test.rb

credit : thanks to Datanoise guys out there and Achmad Gozali of id-ruby to make this happen