With the first release candidate of Rails 2.1 now out, I’ve tested friendly_id against it today. Yeah, I’m not really a big “edge” guy. In case anyone was worried, it appears to work fine. Let me know if you discover otherwise.
I’ve been working with Git for the last few weeks and have decided to move friendly_id over to Github. The svn repository will remain live for at least a month of so after Rails 2.1 is released, since the support for git-hosted plugins is currently only available in Edge Rails.
For now, all development is being committed to Git, and then patched into the svn repository. So, if you’re using the svn repository don’t worry, it will remain current for a while.
I remember first hearing about Git during the Linux/Bitkeeper contoversy, and recall thinking Linus Torvalds was odd for not using CVS or Subversion over Bitkeeper, and then thinking he was certifiably insane for deciding to roll his own version tracking system once Bitkeeper didn’t work out.
Of course, Linus Torvalds is (a) a better programmer than me and (b) smarter than me, so there you go. Git has evolved into a very nice tracking system; for me everything that was slow and annoying in SVN (namely, comparing revisions and branching) is fast and easy using Git. If you haven’t yet taken a look at it, you should.
You can take a peek at the shiny new friendly_id repository here.
If you’d like to see a quick introduction to Git, take a peek at Sebastian Delmont’s presentation below.
GIT Talk (nyc.rb) from Sebastian Delmont on Vimeo.
I got stuck for a few minutes trying to figure out how to write a unit test to check if a value was being set in the flash using flash.now. In Rails’ Test::Unit you can’t just do something like assert_not_nil flash[:notice] because the flash value is discarded at the end of the request, and so the flash is always nil.
The solution is to use Mocha to mock an instance of ActionController::Flash::FlashHash and capture the value being set. Here was my solution:
def test_create_with_empty_email_sets_error_in_flash
hash = {}
ActionController::Flash::FlashHash.any_instance.expects(:now).returns(
hash
)
post :create
assert_not_nil hash[:error]
end
Friendly_id is a plugin for Ruby on Rails which allows you to work with human-friendly strings as well as numeric ids for ActiveRecords, so that you can have urls like “/members/joe” rather than “/members/123” or “/members/123-joe”.
This provides your application with better search engine optimization (SEO), better data security, and more human-friendly URL’s.It can optionally keep track of modified ids, so that you can do 301 redirects the current URL’s of updated resources.
Read more in the RDoc, or download it directly from its subversion repository.
app_config is a small generator for Ruby on Rails that generates an application.yml file in your config director, and an initializer script to load it. You can then use the application.yml file to store API keys, mail server settings, or any other kind of configuration data that your application needs. The code was inspired by Geoffrey Grossenbach’s Ruby on Rails Code Review pdf.
Code