BaseApp: a quick start for your Rails App
For the impatient: http://github.com/ariejan/baseapp
Got issues? Feature requests or patches? http://baseapp.lighthouseapp.com/
Every Rails developer has at least once developed an application that needed user authentication and some basic UI features like tabs and a sidebar. Ask yourself now: “how often have you installed and extended the restful_authentication plugin?”.
Yes, I have done it quite a few times and everytime I find myself writing the same code over and over again. User login, password reset, ‘forgot password’ functionality. I’ve build the same basic UI over and over again. Added administrator users and roles.
Are you tired of doing the same old things over and over again? I was! So, I created BaseApp.
BaseApp is a Ruby on Rails application which contains a lot of code you want in your project by default. To give you an idea of what is does out of the box:
- User Authentication including password recovery, account activation and account suspensio.
- Admin interface where the admin user can easily manage users and tweak app settings
- Default CSS-based UI with tabs and a sidebar. Very acceptable by default and easy to customise.
BaseApp is currently based on Rails 2.1.1. And although it’s a pretty complete package and ready to be used for your next project, it still needs a bit of work. Check out the README for features that should be in BaseApp.
Of course, BaseApp is open source so fork a copy at the GitHub and send me those patches (of pull requests)!
There are tons of feaures that can be included into BaseApp, so the next big thing is to include some sort of configuration that allows you to disable/enable certain BaseApp features.
So, go right ahead! Use it! Fork it! Send me those pull requests!
JRuby with Thomas Enebo
This morning I attended another JRuby talk, this time with Thomas Enebo. It turned out to be, almost default, Sun JRuby talk.
There was one interesting difference, though. Normally we are shown how to run Ruby on Java and how to use Java components in our Ruby apps. Thomas took JMonkeyEngine (a java 3d scenegraph/game engine) and showed that he coded a simple game in Ruby, steering clear of the rather complex Java code.
This is, of course, another great feature of JRuby, you can code a “Java” app, and in certain places actually use Ruby to write cleaner or “easier” code.
Well worth the time!
Panel Discussion with DHH and Rails Core Members
Yesterday evening we attended a panel discussion with DHH and Rails Core Members Jeremy Kemper and Michael Koziarski.
DHH elaborated on default choices (like database, templating system and test suite) after being asked if Rails would switch over to RSpec instead of TestUnit. The answer was that Rails offers several defaults, which should suffice for new and basic users, who don’t know about all options and just want to get started. More experienced users will generate a taste for different components and Rails should provide for easy integration of these components if needed.
All in all there wasn’t any really new stuff to be heard, but a nice gathering non the less.
JRuby with Nick Sieger
A tutorial on JRuby with Nick Sieger holding your hand is just great. This guy knows JRuby inside-out and he has an answer to even the most difficult of questions.
After a short 15 minute introduction, Nick left us with our Rails app to start it with JRuby on a mongrel. I’ve been toying around with JRuby a bit before, and this was rather easy. Some people, however, encounter some issues with their apps because of incompatible gems, like OpenSSL or RMagic which are not available for the Java platform. Luckily, there are some nice Java alternatives like JRuby OpenSSL and ImageVooDoo. My app didn’t suffer from these issues, but from what I’ve heard, these alternatives work great.
Next for the big work: creating a WAR file and deploying it. I’ve done this before, and it’s dead easy. In stall the Warble gem, warble your Rails app and deploy the resulting WAR file.
Nick also talked about the differences between using the JVM and Unix. The biggest differences are memory management and the creation of new threads/processes.
There are quite a few things that Rails and a Java app server have in common, like logging and session handling. In his sheets (I’ll link to those later), you can see how you can tune your Rails app to make use of these features and improve your apps performance (by not logging and keeping sessions in two different places).
Continuing on the performance of Glassfish/JRuby, Nick shows several graphs on how well JRuby performs. A lot of attention goes to Rails 2.2, which will be thread-safe and what it means for JRuby.
JRuby can run with 1 runtime and fill your CPU with threads to handle requests using native Java threads. To handle database connections, Nick Sieger has written a connection pooling component for ActiveRecord (to prevent every thread having it’s own connection to your database). An unreleased version of warbler was distributed that will allow you to set max_instances to 1. This will create 1 Rails instance and use threading in Glassfish. Of course, this is only useful with Rails 2.2.
This was altogether a great tutorial afternoon. Besides the basic warble-your-app-and-deploy-it, Nick provided a lot of interesting facts and tips about deploying to Glassfish. I already was enthusiastic about JRuby, but now I really have to get my hands on a decent server that will run Glassfish comfortably. This means at least at least 1Gb of RAM, so I think I have found at least one drawback of using JRuby.
RailsConfEurope: The first tutorial
Today, RailsConfEurope 2008 started! Well, at least if you signed up for Tutorial Day.
The first tutorial I’m attending is about Hacking Rails Internals. At first I thought about this as a great way to enhance my own apps and be able to easily integrate other apps like Radiant or Mephisto. However, the more I saw of the demo (it really is more a demo than a tutorial really), the more I disliked hacking Rails Internals.
Basically, you hook your own application code directly into the Rails code to make it jump through hoops. But, this comes at a big price. First of all, your app code is very dependent on a specific version of Rails, so upgrading Rails will most likely break your app and cost a lot of time (and money) to upgrade.
Next, you *are* overriding internal Rails code. You just don’t know if any other code (either yours, Rails or a plugin) depends on the behaviour of that code. So you should probably expect strange stack traces.
So, although hacking Rails to include your own or others code directly is great, it has some major drawbacks you should consider. To quote the presenter “It’s brutish, but it’s how to do it”.
I’m really looking forward to Nick Sieger and his JRuby tutorial this afternoon. I’m all set with Glassfish installed and my Rails app ready.
Leaving for RailsConf Europe 2008
Today a delegation of Kabisa is leaving for RailsConf Europe 2008! We’re going by train this year and we hope to arrive this afternoon around 5.
I’ll keep regular updates here on Ariejan.net about RailsConf and all the things I’ve seen and done.
If you’re going to visit RailsConf Europe yourself, feel free to seek us out and have a chat!
See you at RailsConf!
