Ramaze by Example

November 18, 2008 at 13:18

Filed under: Computing — Pistos @ 13:18

What’s Ramaze?

Ramaze is a fabulous framework that lets you create web applications in Ruby with a minimum of code.

Why Ramaze?

With king of the hill Rails chugging along, and up-and-comer Merb picking up steam, why bother with Ramaze? (If you don’t care about the rationale, you can skip right to the beginning of the tutorial.)

The number one* thing that makes Ramaze stand out from the crowd is that you write very little code and you write it all yourself. No generators.

:O “No generators!? How will I survive? What kind of mad scheme is this?” Relax. It’s all good. Why? It’s all a matter of philosophy.

The Ramaze philosophy

Before Rails, people wrote lots and lots of code when making a web app, and they did it over and over as they did web app after web app. With each new app, they would spend time “ramping up” with just the base application before they got into the real meat of the matter, the core functionality which varied from client to client, application to application. Rails and Merb and their ilk try to make your life easier by generating this “lots and lots of code” for you, so you don’t have to spend time repeating the motions of getting the skeleton of your application coded.

Ramaze takes a different approach. It asks: How about we dump the “lots and lots of code” part altogether? This way, you get the benefit of nearly nil ramp up time, without the gaping jaw effect that hits you after you run a code generator script and sit staring at the big filetree that just sprouted out of the ground (think Jack and the Beanstalk).

So yeah, it’s a matter of philosophy. Sure, the Rails way works for some people. And that’s cool. But if you’re the kind of person who went to your local neighbourhood Rails tutorial, got to the generator part, and went “Okay, what the heck is all this stuff… I thought we were making a Hello World app?” — well by jove, you’ve come to the right place at the right time. Come! Come, and I will show you a wonderful world where it needn’t be so. A world where your code is tiny, yet powerful, and you understand it all, because it was generated — not by a script that someone else wrote — but by your own God-given clever little noodle.

Web development by example: A Ramaze tutorial

Update: This tutorial applies to Ramaze 2009.03 and prior. It probably won’t work under Ramaze 2009.04+.

Thus begins our adventure into Ramaze, the web framework. I will lead you through the making of a non-trivial Ramaze application, using the same parts and features you would use in your own killer, take-the-world-by-storm web app. You will come to know all the basics, and perhaps even some advanced things, too. Along with Ramaze, I will make use of a real-world database and ORM. My personal choices for these are PostgreSQL and M4DBI, but the same techniques and principles easily apply to other options like MySQL, SQLite, Sequel and DataMapper. I may cover usage of these in the future.

This tutorial is based on the earlier work of manveru, namely his todolist tutorial. It is similar to that one in some ways, but differs in other ways. That tutorial is still a good reference, though, so you may wish to go over it when you’re done with this one.

You should have some familiarity with the basics of Ruby and HTML to learn and use Ramaze, but you need not have any prior experience with web frameworks in general. In fact, you are at an advantage if you do not, since you won’t have any preconceptions, habits or conventions that might negatively bias your first impressions and experiences.

Source Code

The full source code for this repository is available at github.com. Each step of the tutorial is a separate branch which builds upon the previous step. To get the code, you should use git, the great version control system.

git clone git://github.com/Pistos/ramaze-todolist-tutorial.git

If you really don’t want to get or use git, github has download links you can use. You can also browse the code online at github by hovering over the “all branches” tab in the menu bar and selecting a branch. I recommend you use git itself, though, because you will be able to easily switch between branches as we progress through the tutorial:

git checkout 1-database

and you’ll also be able to see what was added and what changed in the codebase from step to step:

git diff 5-controller 6-add-task

Live Support

The Ramaze community is most active in IRC. Our home channel is #ramaze on irc.freenode.net. If you have any questions before, while or after going through this tutorial, feel free to drop by. I myself (Pistos) am there from time to time, but there are usually others around available to answer questions. There’s also the Ramaze mailing list.

So let’s begin with Part 0: Installation and Preparation.


* “Our chief weapon is surprise…surprise and fear…fear and surprise!”

  • Share/Save/Bookmark

Related posts:

  1. Ramaze by Example - Part 0: Installation and Preparation
  2. Ruby on Rails - Steering Is Futile
  3. M4DBI - Models (and more) for DBI
  4. Ramaze by Example - Part 1: Database Schema
  5. Managing web application errors with Hoptoad and Ramaze

18 Comments »

  1. Pingback by Catholicism Computes » Ramaze by Example - Part 0: Installation and Preparation — November 18, 2008 @ 13:20

    [...] is part 0 of Ramaze by Example, a tutorial on web [...]

  2. Pingback by Catholicism Computes » Ramaze by Example - Part 1: Database Schema — November 18, 2008 @ 13:26

    [...] Ramaze by ExampleCatholic Reference ExtensionDiakonos - version 0.8.6How to exclude directories with tarDiakonos - version 0.8.5 [...]

  3. Pingback by Catholicism Computes » Ramaze by Example - Part 2: Base Application — November 18, 2008 @ 13:36

    [...] by Example - Part 0: Installation and PreparationRamaze by ExampleCatholic Reference ExtensionDiakonos - version 0.8.6How to exclude directories with [...]

  4. Pingback by Catholicism Computes » Ramaze by Example - Part 3: Model — November 18, 2008 @ 13:40

    [...] by Example - Part 1: Database SchemaRamaze by Example - Part 0: Installation and PreparationRamaze by ExampleCatholic Reference ExtensionDiakonos - version [...]

  5. Pingback by Catholicism Computes » Ramaze by Example - Part 4: View — November 18, 2008 @ 13:42

    [...] by Example - Part 1: Database SchemaRamaze by Example - Part 0: Installation and PreparationRamaze by ExampleCatholic Reference [...]

  6. Pingback by Catholicism Computes » Ramaze by Example - Part 5: Controller — November 18, 2008 @ 13:43

    [...] Ramaze by Example - Part 3: ModelRamaze by Example - Part 2: Base ApplicationRamaze by Example - Part 1: Database SchemaRamaze by Example - Part 0: Installation and PreparationRamaze by Example [...]

  7. Pingback by Catholicism Computes » Ramaze by Example - Part 6: Adding Tasks — November 20, 2008 @ 13:10

    [...] Catholicism Computes: Ramaze by Example - Part 5: Controller [...]

  8. Pingback by Catholicism Computes » Ramaze by Example - Part 7: Checking off Tasks — November 21, 2008 @ 11:30

    [...] Catholicism Computes: Ramaze by Example - Part 6: Adding Tasks [...]

  9. Pingback by Catholicism Computes » Ramaze by Example - Part 8: Deleting Tasks — November 22, 2008 @ 09:53

    [...] Catholicism Computes: Ramaze by Example - Part 7: Checking off Tasks [...]

  10. Pingback by Catholicism Computes » Ramaze by Example - Part 9: Layout — November 23, 2008 @ 10:09

    [...] Catholicism Computes: Ramaze by Example - Part 8: Deleting Tasks [...]

  11. Pingback by Catholicism Computes » Ramaze by Example - Part 10: Cosmetics — November 24, 2008 @ 09:29

    [...] Catholicism Computes: Ramaze by Example - Part 9: Layout [...]

  12. Pingback by Catholicism Computes » Ramaze by Example - Part 11: Validation and Error Handling — November 25, 2008 @ 22:52

    [...] Catholicism Computes: Ramaze by Example - Part 10: Cosmetics [...]

  13. Pingback by Catholicism Computes » Ramaze by Example - Conclusion — November 26, 2008 @ 15:19

    [...] Catholicism Computes: Ramaze by Example - Part 11: Validation and Error Handling [...]

  14. Pingback by Justkez » Ramaze livesearch with jQuery — January 8, 2009 @ 11:11

    [...] the basics of Ramaze worked out. If you are not too familar with the framework, I would reccommend Pistos’ excellent “Ramaze by example”. The steps involved [...]

  15. Comment by wlb — March 23, 2009 @ 00:33

    Tutorial looks nice. But about Git clone & checkout: am I doing something wrong here? (Judging from the Git documentation, your commands should work as is, but they don’t for me.) After cloning your repository, I do

      git checkout 1-database
    

    and I get the following message:

      error: pathspec '1-database' did not match
      any file(s) known to git
    

    when I add ‘-b’ to the command, it accepts it, but there is no change to the working directory: there’s only the README that was there from the start. After the first checkout with ‘-b’, subsequent checkouts without ‘-b’ succeed, but there is still no change to the working tree. Just that lonely README file. Is there a problem with the repository or with my understanding of Git? (Using Git 1.5.6.2 on OS X)

    Looking forward to working with your code and your interesting tutorial.

  16. Comment by Pistos — March 23, 2009 @ 08:37

    wlb: Sorry — I gave erroneous git instructions. When you clone, the branches are only available as remote branches. Check them out with:

    git checkout origin/1-database
    

    That is, by referring to the remote with a “origin/” prefix. To set up a local tracking branch, use this:

    git checkout -t origin/1-database
    

    And from then on you will have a local branch to work with, like so:

    git checkout 1-database
    

    Sorry for this mixup, I guess I should have tried to use the repo as an anonymous git user.

  17. Comment by wlb — March 24, 2009 @ 02:18

    Great. That does it. Thanks.

    Wm

  18. Pingback by Rails Alternatives: Merb, Sinatra & Ramaze — xambr::blog — crafting my thoughts — May 28, 2009 @ 00:36

    [...] well written examples of ranging in size from hello world to a social networking site and a great set of blog posts by [...]

RSS feed for comments on this post. TrackBack URI

Leave a comment

You may use Markdown syntax in your comment.

Powered by WP Hashcash

Powered by WordPress.