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
Speaking of freckle extractions:
Amy did a Jump Start Credit Card Processing Cheat Sheet for this year’s Ruby Advent. It is based on experiences from our work on freckle.
The sheet also includes some Javascript goodness from Thomas which he details on his blog.
Stubbing named_scope calls can be a real nightmare. If you use Rails’ named scopes as often as I do, you probably know this.
Imagine this code in a controller:
1 user = @account.users.activated.find_by_email
Using off-the-shelf Mocha you would stub it with something like the following:
1 @account.stubs('users').returns(mock('users', :activated => mock('activated', :find_by_email => users(:kommen))))
This doesn’t fit my coding style though. So lets fix this.
With this little monkey patch extracted from freckle you can now do this:
1 @account.stub_path("users.activated.find_by_email").returns(users(:kommen))
Now we can talk.
Redcloth 4.0: was just released and according to Jason Garber it is 40 times faster than the previous version.
Sounds like a huge speed up for textilize and co. I guess it will be shortly available through the rubyforge gem severs.
RubyGems 1.2.0 was released yesterday and the announcement starts like this:
RubyGems no longer performs bulk updates and instead only fetches the gemspec
files it needs.
Finally! This should save me quite a lot of time, since I have gems.github.com as a gem source and it often had to update 300+ gemspec files.
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
webstock conference —
We were there!