Rails on the Run

Rails experiments by Matt Aimonetti

Browsing Posts tagged san diego

merbcamp

That’s now finally official, MerbCamp 2008 registration are open! What an exciting time!

History

To understand why I’m excited, we need to go back few months back. Merb was first released by Ezra has an alternative tool to handle file uploads. Merb came to reality because Ezra needed something fast, light and flexible to handle something that, let’s be frank about it, Rails had a hard time dealing with. Rails was king but was not as popular as now. Merb started as a simple Mongrel handler, in other words an alternative for small, light limited actions. Most people started using Merb simply to handle uploads. But as few cool kids started using Merb, they thought, hey, this thing is super fast, maybe I can use it to build small standalone apps. After all, hardcore developers don’t need “cool ajax helpers” and form builders to create a simple site. [Geoffrey Grosenback]() aka topfunky even proudly used Merb to reduild his site!
That was just enough to convince me to start using Merb back at version 0.3.4.

I was an active Rails user and contributor. Having to use a bare bone Ruby web framework was quite refreshing however the lack of testing framework was a real show stopper :( (Being hooked up on RSpec by Josh Knowles I ended up only writing a small portion of a Rails app with Merb 0.3.x (uploader backend).)

Quite quickly Merb’s philosophy changed and switched. The Mongrel handler framework started dreaming of becoming an alternative to Rails. Merb took the best from Rails but targeted another audience: the Ruby hackers living on the edge.
Merb prides itself in being less opinionated than Rails(that can be argued tho), ORM agnostic (supporting ActiveRecord, Sequel and DataMapper), Javascript framework agnostic and truly modular. People like Yehuda Katz, Michael Klishin aka antares got involved, as more contributors joined the effort, rules were enforced to make sure the framework would be as fast as possible and easy to extend without monkey patching. (ohh and fully tested using RSpec ;)

Engine Yard decided to support the development effort and helped with Merb’s major rewrite (0.9 versions). Today, Merb is divided in 3 repositories, merb-core, merb-more and merb-plugins. By letting developers only choose what they want to use and by following a principle of isolation with private/public APIs, I believe Merb is today the most flexible yet powerful Ruby framework available.
Furthermore, even though many people don’t understand the purpose of rewriting a “new Rails” from scratch, the reality is that many progress made by the merb team were ported back to Rails and inspired others (DataMapper for instance)!

Anyway, this is not a sale’s speech and I’m not trying to convince you to use Merb. My point is that Merb is finally coming to a point where the public API is stable and where one would find most tools he needs to build production ready applications.
And, that’s basically a long sum up explaining why I wanted to organize something special to celebrate the 1.0 release and to create more awareness around Merb’s awesomeness!

The Team behind MerbCamp

I started getting involved with the SDRuby community a couple of years ago. As I got to know more people I realized that many people lead by Patrick Crowley (leader of SDRuby and one of the organizers of SD BarCamp) had the desire to organize a local Ruby conf/camp.

At the same time, while I was working daily with Merb and contributing back to Merb’s code, many other SDRuby fellows were also getting really excited about Merb (Rob Kaufman, Ryan Felton to mention a few).

Seeing the opportunity to host the very first Merb event in San Diego (host of RubyConf 2005!) I chatted with yehuda and the rest of the merb team. All the merb people were really excited, Leah Sibler from Engine Yard even offered her expertise to organize such an event (she’s totally awesome at planning/running conferences).

However, setting up such an event isn’t something one can do on his own. Before promising anything, I checked that Rubyists from San Diego would be interested and would help. In no time, I got a lot of people offering to help.

The key thing for me was to get someone with a good experience in organizing conferences. A person with resources and contacts. The only person I knew in San Diego who would be good enough to do that was Patrick Crowley. We had a quick chat Patrick and I and it turned out that Patrick was very excited about organizing the very first MerbCamp in his town.
Patrick quickly got a team together who agreed on working on the project. We got back to the Merb team and sealed the deal.

Patrick even found the awesome venue that many other cities will envy us! He’s been running the show, running here and there, making phone calls to make sure registration would open on time, setup the website etc…. Thanks Patrick!

The Conf

MerbCamp will be an hybrid between a BarCamp, a conference and an unconference. When the organization team got together, we all agreed that what we like the most during conferences is networking. We certainly also enjoy some good talks and definitely enjoyed the hack-room during the last Rails Conf. We therefore decided to organize a conf *we* would love to go.

  • 1 scheduled track with “official talks” to make sure we have some serious content and to motivate people to signup ;)
  • BBQ at the beach, because we live in San Diego and we love that! (plus, big open meals are the best way to network)
  • BarCamp type impromptu talks
  • hack-rooms so people can work together
  • friendly and small conference (we limited the amount of participants to 200)

To conclude, I hope the “history” of MerbCamp 08 wasn’t too boring. People seem quite excited about this event, we even have guys in London who would get together to watch the talks via a webcam we are going to setup for them.
We hope to see you there, if not, we hope you’ll organize your own conference and we will come have fun with you.

If you’ve read my post on Ajax pagination you know that I’m a big fan of Dan Webb’s LowPro unobtrusive javascript library.

Doing Unobtrusive Javascript (UJS) is basically registering event handlers programmatically using CSS selectors to select the elements to register. In other words : keeping things separate and avoiding inline javascript.

If you’ve been using LowPro 0.4 and recently tried to upgrade to Prototype 1.6 you probably noticed that things don’t work as they used to.

The first thing you want to do, is to update to the latest version of Lowpro.

So what’s new in 0.5 trunk?

First off, you need to know that a lot of lowpro features were moved in Prototype 1.6 core :)

  • You now get a warning via firebug if you try to use Low Pro with a version of Prototype that its not designed to work with.
  • Alternative event system ripped out: uses core events
  • DOM method mixins ripped out: alternatives all in prototype
  • Event.onReady delegates to the new dom:loaded event. However this doesn’t fire immediately if the dom is already loaded like Event.onReady did. (might be patched to work as before)
  • DOMBuilder is staying but now is a thin shell around the new proto 1.6 Element stuff.
  • You can still return false from event handlers in addEvent and Behaviors to stop the event but now if you use Event.observe raw you don’t get this.
  • Behavior.create now works like Class.create in 1.6 so behaviors can have full inheritance:
1
2
3
4
5
6
7
8
9
10
11
12
  Basic = Behavior.create({
   onclick: function() {
    alert('woo');
   }
  });

  SuppedUp = Behavior.create({
   onclick: function($super) {
    alert('wee');
    $super();
   }
  });

Works really nicely.

  • core behaviors : Remote and Observed are now moved into the lowpro core (you don’t need to include the external files).

  • Event.addBehavior.reassignAfterAjax defaults to false. If you want re assign behaviors after an ajax call, you need to turn this option to true.

  • Event.addBehavior.reload(); added to reload/re assign behaviors. Very useful if you dynamically insert elements you want to observe!

  • new website has been set up and will contain documentation and tips – Full API docs coming soon. There’s also a dedicated google group.

Here is a quick example with real life code. (which could be refactored, I know)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Make sure the behaviors still work even after navigating to another page using the ajax navigation.
Event.addBehavior.reassignAfterAjax = true;

// Behaviors
Event.addBehavior({
  // Pagination links  
  'div.pagination a' : Remote.Link,

  // Reset the list when a user clicks on cancel.
  'a.cancel_button:click' : function() {
    $('list_of_things').update("");
  },

  // carousel navigation prev
  'a#carousel_prev:click' : function() {
    moveCarousel('prev'); return false;
  },

  // carousel navigation next
  'a#carousel_next:click' : function() {
    moveCarousel('next'); return false;
  },

  'div.panel_pic:click' : function() {
    removePanelPic(this);
  },

  'div.photo_from_row img:click' : function() {
    // Get the div holding the pic and use it as a target
    var target = this.up();
    addPicToPanel(target);
    new Effect.Highlight(target);
  }
});

function addPicToPanel(target){
  new Insertion.Bottom('control_panel_photos', "<div id='edit_"+ target.id +"' class='panel_pic'><img class='panel_pic' src='" +  target.immediateDescendants()[0].src + "'/></div>");
  // Reload the behaviors so the new inserted pic can be monitored 
  // and the 'div.panel_pic:click' behavior can be triggered
  Event.addBehavior.reload();
}
  

LowPro is a great way of keeping your code really clean and your views very accessible.

If you are interested in knowing more about UJS, come to our SDruby group meeting on Dec 6 @ 7:30pm (directions). And if you don’t care about UJS, come later to hear about Facebook API. Don’t forger to bring your questions for our first Rails roundtable.

A bit more than a month ago I posted a tutorial on how to use Flash with Rails to create some awesome/sexy graphs.

chart

Since a lot of people seemed interested by the topic, the SDRuby guys asked me to do a intro talk on how to create Sexy Charts with super sexy Rails.

In the mean time, a lot of people were asking for a example app to look at. People knowing me know that I’m quite lazy and I don’t like repeating tasks. I therefore decided to kill 2 birds with one stone and wrote a demo app that I would use during my presentation

As I was writing the demo app, I quickly realized that my talk would be even sexier if I would show some best practices. After all, an introduction talk is meant to help newbies learning the tricks that will change them in ninjas!

Sexy charts are sexy now, but in 15 years they might not look so sexy anymore. However BDD is super hot now and will always be sexy! (even though we’ll probably adopt other even hotter approaches).

Based on the circumstances I decided that Sexy charts would become an excuse to show people how to do BDD using RSpec and how to test a XML view as described in this previous post

During my presentation I totally forgot to show people what what kind of XML we were trying to feed amCharts, so here is the file:

http://pastie.caboo.se/120055

The code used in the presentation is also available here

Presentation available here (the sound is a bit saturated, sorry about that. Note that we made the video big enough so you can follow with the code if you don’t understand my accent :) )

Feel free to watch the other SDRuby podcasts or even better, subscribe to our feed.

Next SDRuby meeting will be Thursday, December 6 @ 7:30pm

Location: UCSD CS Building

We’ll be talking about Unobtrusive Javascript, the Facebook API, and hosting our first Rails Roundtable.

Newbies and experts welcome!