January 17, 2008 at 5:06 am
· Filed under DataMapper, Merb
I have been experimenting with Merb for a while as an alternative to Rails.
Compared to Rails, Merb is a lightweight framework. By default Merb strips away a lot of unnecessary cruft, and in doing so does not include a default Object Relational Mapping (ORM), such as the popular ActiveRecord. Though this doesn’t prevent it from utilizing one, you are given the option of using a variety of frameworks to satisfy your application’s needs. Presently Merb supports ActiveRecord, DataMapper, and Sequel.
Out of the three I decided to experiment with DataMapper, as I was already familiar with ActiveRecord, and wanted to explore something new.
When using the default settings, DataMapper doesn’t log the queries! This makes it extremely difficult to debug an ORM especially when you are new to it.
Enabling Logging
Luckily you can add two keys :log_stream and :log_level to your config/database.yml to enable logging.
:development: &defaults
:adapter: sqlite3
:database: application_development
:log_stream: STDOUT
:log_level: 0
Disabling Logging
Now When going into production mode, you should (if you desire) turn logging off.
:production:
<<: *defaults
:database: application_production
:log_stream: nil
Permalink
January 11, 2008 at 3:39 am
· Filed under MacPorts, do_postgres
Ensure that pg_config is in your $PATH.
Note: This expects you are using PostgreSQL 8.2. Alter the directories as required.
To test if pg_config is included, execute which pg_config
:
Expected Result:
/opt/local/lib/postgresql82/bin/pg_config
Including pg_config into your $PATH
If you don’t get anything, then it isn’t in your path. Append the following to your ~/.profile file:
export PATH=$PATH:/opt/local/lib/postgresql82/bin
Now it will be included in all new terminal sessions.
Installing do_postgres
Now feel free to install the do_postgres gem.
sudo gem install do_postgres -- --with-pgsql-include-dir=/opt/local/include/postgresql82/ --with-pgsql-lib-dir=/opt/local/lib/postgresql82/
Note: This is a single line command.
Permalink
December 11, 2007 at 2:53 am
· Filed under FSEvents, RubyCocoa
When developing a Rails plugin, you are required to restart the server so that your plugin will be reloaded. You’ll notice that after a while this becomes a rather tedious process, especially if you are working on a hot-off-the-press new plugin.
Following suit on my autotest with FSEvents, I opted to listen for any changes to the vendor/plugins and lib directories to restart the server as required. Thus freeing me of the horrible grunt work of restarting the server.
Note: This is Mac OS X 10.5 Leopard specific.
The Incantation
Create the required file script/autorestart_server, and put this beauty in it.
For an easy to copy dump, click “view plain“.
Note: Don’t forget to make it executable! chmod u+x script/autorestart_server 
Automatically Restarting script/server
Now feel free to execute script/autorestart_server 
Wondering where else I can inject FSEvents into, its quite a handy little tool…
Permalink