Samstag, Juni 28, 2008

Render a simple Javascript with Rails

Though its a simple task there is no well documented solution. Most I googled did not work. I just needed to write a large javascript array dynamicly. If you just do a render :text => js your resulting content type will be text/html which was a problem for the IE. But setting the mime_type like

render :text => js,:mime_type => Mime::Type.lookup("application/javascript")

does not do the trick. What you have to do is setting the content type in the headers variable:

headers["Content-Type"] = "text/javascript".

I got the best results when I also added a .js to the route so you can call it like a static javascriptfile. If you want to do more complicated things you may check out the minus_r plugin of Dan Webb:

Freitag, Juni 20, 2008

Fat model

Today I had the chance to enjoy a dinner with David Black and some other Ruby folks in Berlin. We were discussing about legacy Rails code. Many newbies tend to write fat controllers with many pages of codes and 30 something methods. One was arguing that this is also Java style. I am now thinking thats not prefered even in Java though it was engouraged in J2EE because Entity Beans had been such a crap. Its just functional programming style where you end when you dont understand object orientation.

Montag, Juni 16, 2008

state of the art javascript gui

That gui of the north280 guys is really awesome. you have got to check out their presentation tool. everything is so smooth, it doesnt look like a webgui. at least with my Safari. If you want to read about the background story and the developers tuaw has more. hopefully they publish their javascript libraray objective-j soon.

Samstag, Juni 14, 2008

Merb presentation

While I heard a lot of postive stuff about merb I had no time to play with it, but this presentation on confreaks is definitly worth seeing. Ezra Zygmuntowicz explains some of the advantages of merb. I like the idea of a hacker should understand his framework he is working with. Therefor no magic in the framework. The magic is for your code. What I found interesting as a Rails developer he also has some concrete critics at Rails, mainly at the Actionpack where he started refactoring some really old parts there.