I recently heard some whispers that Rails and Merb are going to be merged and the result should be call “Rails 3”. I simply couldn’t believe it–at least until the bombshell dropped on blogs and on twitter.
Enough has been written on what this is all about so I won’t duplicate it here–just my 2 cents.
Overall, I think this is a huge thing for the ruby community. I always had an eye on Merb and considered it more than once for a new project. Main reason: Performance. However, I never made the move. So I’m happy to see that all the corner stones of Merb are going to hit Rails’ code base soon. Besides the performance stuff, I’m looking forward to have a stable API for plugins. This should make it a lot easier and less work to maintain plugins for Rails.
To quote David:
Rails 3 is going to kick ass.
The current version of timed_fragment_cache from Richard Livsey is not yet compatible with Rails 2.2.
I’ve added a patch to my fork of the plugin on github, which makes it compatible with Rails 2.2 by using the new output_buffer method instead of a binding.
Note that the change breaks compatibility with earlier versions of Rails. So use my fork only with Rails 2.2 or later.
You can find the code here: timed_fragment_cache
A thing which annoyed me for a long time since switching to RSpec was the
incorrect recognition of RSpec and Rails files.
If you told TextMate to use the RSpec bundle for the spec files, it also used
it for the Rails files.
Now I found the solution for this on the TextMate blog:
http://blog.macromates.com/2007/file-type-detection-rspec-rails/
Mislav just posted this in #rails-contrib on irc.freenode.net: Pastie
This little script checks your existing Rails application for Rails 2.0 compatibility. Should be very useful for everyone
who wants to upgrade and use the latest and greatest Rails features.
It will give you rough clues about where you have to get your hands on.
As I wrote some time ago, we protect our blog with Akismet against spam.
For those who don’t follow Ryan Bates’ Railscasts (I really suggest to do so) I want to introduce Akismetor. It’s a small library that simplifies the use of Akismet. I really recommend watching this free screencast about how it works or alternatively you can read the Akismator README.
Today 3 years ago, DHH released Rails to the public.
Happy Birthday Rails and thanks to all contributors to make me enjoying web development so much!
Joe and I currently are in Ostrava on the Ostrava on Rails Conference.
The first day of the conference (where all presentations were in english) is over. Tomorrow there will be presentations in czech. Today 10pm there is a party in the city center of Ostrava. Luckily the party is just a few meters away from our hotel. :-)
Here is the photostream from the arrival and the conference: http://flickr.com/photos/unkai/sets/72157600421346067/
The last RadRails version 0.7.2 was released 3 months ago and it seems the RadRails-Team members are spending their time on other things. RadRails isn’t feature complete yet and there are still many bugs bugs waiting to be fixed.
And honestly, I don’t like to work with software, which needs some work but isn’t under maintenance/development any more.
So I (again) took a look at other Rails editors/IDEs to try out. After playing around with vim and emacs I decided to give emacs a try.
As Joe wrote in the article about our shiny new blog, he mentioned that we now use Text-Link-Ads for doing advertising on our blog.
Text-Link-Ads provide some adcode for Ruby On Rails applications, but using their code is not as convenient as it could be. Also, I had problems with some parts of it:
It seems that they overwrite a Rails method (request) which meshes up the application until you rename it.
I did some modifications to the adcode so I could use it more easily in the system. Then I extracted the code and created a Rails plugin. This plugin I want to share.

soaked and soaped has redesigned. What you see in front of you is a new layout paired with everything Rails 1.2 offers for us programmers.
I just want to highlight two very well written and helpful RadRails tutorials posted on the radrails.org blog:
Rolling with Ruby on Rails
and How To Setup/Configure Eclipse SQL Explorer Plugin
Recently, when I switched from Ubuntu Dapper Drake to Edgy Eft, I also had to set up my development environment again.
This time I decided to use SQLite3 for Rails development on my notebook instead of MySQL.
I used to administer my databases with phpMyAdmin or with the Data Perspective in RadRails. Now my problem was, that the SQLite JDBC driver which RadRails uses sucks and the Data Perspective wont work.
So I looked for a solution to easily manage the SQLite databases from my projects with RadRails.
Here it is:
rSQLiteGUI is a very simple but useful graphical interface to manage SQLite databases written in Ruby and using GTK2.
To install it, just download the latest version from here and extract the archive to a directory. Make sure rsqlitegui.rb is executable.
In RadRails you can define File Associations. So associate the *.db files with rSQLiteGUI:
*.db*.db entry in the File types listrsqlitegui.rb file.Done! Now you can view or edit a SQLite database just double clicking on it in the Rails navigator.
I just came across a new interesting site: The Rails Way
From the About:
The Rails Way is all about teaching “best practices” in Rails application design. It is run by Jamis Buck and Michael Koziarski, both of whom are members of the Rails core team and have had extensive experience with both designing and building web applications.
Spam is more and more a problem for many sites. And there are many approaches to fight spam. One is Akismet.
Akismet is a collaborative effort to make spam a non-issue. While there are Akismet plugins for Typo, WordPress, etc. you have to do some work to use it in your own application.
In this article I will demonstrate how to use Akismet in your own
Rails application to protect it against spammers. As example I will use comments, e.g in a weblog.
I’m assuming you already have your blog up and running, and want to add spam protection with Akismet.
Akismet is free for personal use. But for using it, you have to get a key. Either a commercial or a personal one.
So go to http://akismet.com/ and get one.
For the personal one you will get redirected to the WordPress signup. If you just
want the key for your application, choose the option Just a username, please..
After submitting the form, you’ll get an activation email. Click on the link in the email
to verify your email address. Then you will get another email, which contains your
user data and your Akismet key labeled with API Key:.
David Czarnecki has written a Ruby interface that you can use in your application to easily access the Akismet API.
Download the akismet.rb file from here:
http://soakedandsoaped.com/files/akismet.rb
and put it in the lib directory from your Rails application.
The filename has to be akismet.rb. (case sensitive!)
In your controller write a little helper function that checks comments for spam.
This could look like this:
1 2 protected 3 4 def check_comment_for_spam(author, text) 5 @akismet = Akismet.new('< your Akismet key here>', '<your blog url here>') # blog url: e.g. http://sas.sparklingstudios.com 6 7 # return true when API key isn't valid, YOUR FAULT!! 8 return true unless @akismet.verifyAPIKey 9 10 # will return false, when everthing is ok and true when Akismet thinks the comment is spam. 11 return @akismet.commentCheck( 12 request.remote_ip, # remote IP 13 request.user_agent, # user agent 14 request.env['HTTP_REFERER'], # http referer 15 '', # permalink 16 'comment', # comment type 17 author, # author name 18 '', # author email 19 '', # author url 20 text, # comment text 21 {}) # other 22 end
Your create method could look like this:
1 2 def create 3 @comment = Comment.new(params[:comment]) 4 unless check_comment_for_spam(@comment.author, @comment.comment_text) 5 if @comment.save 6 flash[:notice] = 'Comment was successfully created.' 7 redirect_to :action => 'list' 8 else 9 render :action => 'new' 10 end 11 else 12 # Spam detected! Do something with the spammer. 13 flash[:notice] = 'Go away!' 14 render :action => 'new' 15 end 16 end
You can test your spam protection by trying to create a comment with author set to viagra-test-123
Akismet should always say that this is spam.
You’re done! Akismet is now watching at your comments and blocks spammers!
Note that you can submit spam also! Use the submitSpam function of the API.
Ryanb has posted two tutorials in which he explains how to create and edit two models at the same time in one form.
In his example the models are releated with _has_many_ and _belongs_to_.
Creating Two Models in One Form
and
Editing Multiple Models in One Form
This article shows how to refector your Rails application by moving some code from the view to the model.
Ryanb also explains how to use Unit Tests for that process to ensure nothing gets broken while cleaning up the code.
See the complete article here
Yesterday danger posted a nice tutorial about writing your own Rails plugin.
I found that very useful, because I didn’t know how easy it is to write your own plugin.
And I think it’s interesting for everybody else who wants to write his own one.
Here is the link:
The railsforum.com admin-team has announced a tutorial competition. The one who posts the best tutorial there until November 1st, wins an new iPod shuffle with 1 GB space.
For more details read the announcement.
I’m looking forward to see some good tutorials.
Yesterday, while fighting against spam on the Ruby on Rails wiki, I came over a nice gem: Chronic
With Chronic you can easily parse natural language date and time formats into a DateTime object. You don’t have to mess around with regex to parse things manually. As gem, it’s easy to install and it’s also very handy to use.
$ gem install chronic
Thats it.
Put this in your model or controller file:
require 'chronic'
Then you can use Chronic.parse in your methods. E.g. Chronic.parse('tomorrow'),
Chronic.parse('monday', :context => :past), Chronic.parse('this tuesday 5:00')
Or more complex: Chronic.parse('3rd thursday this september'), Chronic.parse('3 months ago saturday at 5:00 pm')
And of course it can do a lot more! For a complete reference and more examples see chronic.rubyforge.org
1 You can also use Chronic to validate malformed date strings: 2 3 class Meeting < ActiveRecord::Base 4 5 def validation 6 errors.add :meeting_date, 'is not a valid date' if Chronic.parse(meeting_date.to_s).nil? 7 end 8 9 end
As I mentioned in my last post, RadRails 0.7.1 now supports Mongrel. So I decided to use Mongrel instead of Webrick for development on my notebook. But it was a bit tricky and took me a bit of googling to get it.
As Joe wrote in his post about installing Mongrel on MacOS X, I’ll describe how to install it on Ubuntu, assuming you already have Ruby and Ruby on Rails up and running.
Because Mongrel is partly written in C/C++ for more performance, you have to install the build-essential package. It will install all needed packages so that you can compile C/C++ applications.
sudo apt-get install build-essential
(You can also use the synaptic package manager to install it, if you prefer a GUI)
You also need the @ ruby1.8-dev@ package. When you try to install Mongrel without this installed, it will complain with this errormessage:
extconf.rb:1:in `require’: no such file to load — mkmf (LoadError)
from extconf.rb:1
Install the package with this command:
sudo apt-get install ruby1.8-dev
Then just use gem to install Mongrel:
sudo gem install mongrel —include-dependencies
Gem will ask you, which version of Mongrel you want to install. Choose the latest ruby verion.
Then you’ll see some output from the C/C++ compiler.
Ok, you’re done! Now you can start the server with mongrel_rails in your Railsapp directory.
NOTE: Even without the build-essential package installed, Mongrel will install and say that installation was successful. But when you try to start the server, you’ll get an error message like this:
** Starting Mongrel listening at 0.0.0.0:3000
/usr/local/ruby-1.8.4/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/
mongrel.rb:666:in `register’: undefined method `resolve’ for
nil:Mongrel::URIClassifier (NoMethodError)
For the case you missed it: 2 days ago the RadRails team released version 0.7.1 of their Rails IDE.
I just downloaded it. (the “Update RadRails..” function didn’t work in the old 0.7)
There are some new features and a lot of bugfixes.
See the full announcement here: http://www.radrails.org/blog/2006/9/9/radrails-0-7-1
Notice that they also relaunched their website. There is a community section now.
This is all about how to use Migrations in Ruby on rails to make your work even more productive.
I’m developing with Ruby on Rails since 8 month now, coming from Java and PHP.
But only a few days ago I discovered one powerful feature of Ruby on Rails: Migrations.
I think there are a lot of others (like I was) who develop with Rails, but don’t know how to use migrations and how helpful they are.
For those, here is a litte introduction.
3 weeks ago I read about railsforum.com.
I signed up and joined the community. Currently railsforum.com has 415 members. When I registered, there were about 300. There are a lot of people who read and write on a daily basis.
It’s a small, but friendly and helpful community. You can get answers to trival and also to more complex questions.
Join today if you’re interested and give it a try.
A few days ago I began working on a design for the “soaked and soaped”-blog. Webrick seemed a bit slow for working offline on an app like Typo so I decided to give mongrel a try.
After installing it via RubyGems…
$ sudo gem install mongrel
.. I quickly realized that something went wrong during installation.
I tried to start mongrel in my RailsApp directory but all that happened was getting an error message that HttpHandler doesn’t exist.
I googled a bit and finally found this.
It says that the mongrel installation routine needs a programm called ginstall to work proper. Bad luck, Mac OS X has no program called ginstall, but one which is called install and which resides on another location than ginstall.
So all you have to do, do get mongrel running on OS X is:
1. Uninstall it (if you have already installed it).
$ sudo gem uninstall mongrel
2. Set a symbolic link from the “install”-command to the place, the install script wants to have a program called “ginstall”.
$ sudo ln -s /usr/bin/install /opt/local/bin/ginstall
3. Install mongrel again via RubyGems
$ sudo gem install mongrel
4. After installation is complete, switch into your railsapp directory and start mongrel.
$ cd your/railsapp
$ mongrel_rails start
Yesterday I came over Exception Notifier.
I found it really useful because it is really easy to install and you can instantly react to Application Errors. Your customers don’t have to notify you because you get a bunch of information to track the error via email.
webstock conference —
We were there!