rod mclaughlin

Merb interactive mode:
merb -i
'readline' required

To fix this, get another copy of the Ruby interpreter source code
and recompile it from
source with the --with-readline-dir=/usr option - see

Got ruby-1.8.7-p72.tar.gz from the ruby-lang website and untarred it -

tar xvfz ruby-1.8.7-p72.tar.gz cd ruby-1.8.7-p72 ./configure --prefix=/usr/local --with-openssl-dir=/usr --with-readline-dir=/usr --with-zlib-dir=/usr make sudo make install ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux] merb -i Loading init file from rubyjunction/config/init.rb Loading rubyjunction/config/environments/development.rb ~ Connecting to database... ~ Loaded slice 'MerbAuthSlicePassword' ... ... irb: warn: can't alias context from irb_context. irb(main):001:0> puts 'hello world' hello world => nil

That's a lot just to print 'hello world'...

Migrations - making the database fit the Ruby code

Started merb, added a few fields to model article.rb, and generated a 'migration' which is supposed to add the new columns to the database:

merb-gen migration --model article ... [ADDED] schema/migrations/003_article_migration.rb cat schema/migrations/003_article_migration.rb
migration 3, :article do up do end down do end end rake db:migrate Migration name conflict: 'article'

Doesn't the migration generator know how to name its migrations?

rake db:automigrate
to put the new columns in the table

rubyjunction$ merb-gen migration --model article Loading init file from config/init.rb Loading config/environments/development.rb Generating with migration generator: [ADDED] schema/migrations/001_article_migration.rb

Couldn't find out how to create the test database

So I dumped the development database into a file and loaded
it into the test database before running the tests:
mysqldump -u root db_development > db.sql
and loaded db.sql into the test database from within mysql:
source db.sql

This message, from one of the creators of Merb,
merb-gen resource Page title:string body:text
should be written as:
merb-gen resource Page title:string,body:text
... This is probably quite poorly documented at the moment

A bit of an understatement! I know it's free, but we are spoiled Rails hackers, (web development that doesn't hurt). Merb is web development that does hurt.

Guess which one of these commands works?

merb-gen resource Article title:string body:text created_at:date_time merb-gen resource Article title:string, body:text, created_at:date_time merb-gen resource Article title:string,body:text,created_at:datetime

If you guessed the last one, you have what it takes to be a Merb developer - you're good at guessing

After that, do
rake db:automigrate
to create the table

Unlike Rails, the Merb generator doesn't have a scaffold generator so you can't start using the app a minute after creating it.

However, this link
gives an example of a simple page to create a new article, so I used it.

By the way, I created this site using the Rubymine editor from JetBrains. Best Ruby IDE I've seen.

After a lot of messing about with different AJAX editors, ended up using TinyMCE for editing articles.


One thing that is easier with Merb is imposing a style on all pages.
All I have to do is write a header and footer in application.html.erb
and make sure the following is in the middle of this file:

   <%#= message[:notice] %>
   <%= catch_content :for_layout %>

The text you are reading is the contents of more.html.erb, which gets inserted
where this is in application.html.erb when you go to /more.


Portland London