It has been a while since I last posted a blog on rails. I have been tied up with lots of stuff lately. And I just got my time back to move on with my first Rails project to build QuoteJetty. The ride has been fun, though many times I still have to google to find answers for issues that are not covered in Rails books.
One thing that I bumped into is the usage of flash[:notice].
I found out that flash[:notice] is meant only for redirect action, because the message is only cleared after at the end of redirected view request. So if you don’t redirect the request, and you click on the next request, that message will still be displayed.
But sometimes, we just want to display custom error messages only for current request without the redirection (esp. for non-ActiveRecord error messages). So the option is to use flash.now[:notice]. It clears the flash message at the end of current request (without redirection), e.g.
def some_method
.....
flash.now[:notice] = 'some message'
end
But there is an issue with functional testing using flash.now[:notice]. Since the message is cleared at the end of the request, you won’t be able to retrieve the flash[:notice] value in your functional test. But no worries, here is the alternative check, use assert_tag.
assert_tag compares the actual html output of your test in a convenient way, just like most of Ruby methods. Click here for the API doc.
def test_method
....
....
assert_tag :tag => 'div',
:child => /[replace with your message]/
end
ProgrammableWeb.com is ‘the website’ that showcases mashups around the world.
Today, BookJetty is featured as the mashup of the day. It gets an average rating of 4 stars. Thanks guys for your votes.
I have just given a new look for Pluit Solutions blog.
I found the old design (the image on the left) was not serious enough for a business blog. So I created this new design with that idea in mind.
I also added a shot of myself. Now you would recognise me if we happen to bump into each other on the street.
Flickr was down this morning, yet they gave me some work to do. Don’t you love them?
Bookjetty gets a fresh coat of paint and 3 new sections on the main page:
- Latest Discussions, latest posts in the forum.
- BookJetty Picks, some recommended books to read.
- News and Updates, latest happenings.
You might one to consider this if you can’t afford an iPod. Thanks to DesignSojourn.
RSS feed has been the blood vessel for bloggers. But sadly many blog sites that I bumped into still do not have the RSS feed auto-discovery feature.
This simple feature allows RSS feed reader to auto-discover your feed link by just entering your website url. Isn’t it very convenient? Instead of having to skim through your page layout for the tiny RSS button, the extra click to load your feed link and manual copy and paste the URL to the feed reader.
So how can you do that? Very easy. Edit your page layout, and insert the following tag under the <head> tag, as such:
<head>
...
<link rel="alternate" type="application/rss+xml"
title="[Your Feed Title]" href="[Your RSS Feed link]" />
</head>
The wait is over, BookJetty finally gets its own server, and it is now hosted in Singapore. The response time has improved and it now feels lighter to surf BookJetty.
Some new updates to the BookJetty are:
- A book forum, feel free to recommend some good books you have read lately.
- The URL has been shortened (using URL Rewriting) to be more user friendly and for Search Engine Optimisation (SEO). If you enter the old URL, it will be redirected to the new URL format.
http://www.bookjetty.com/app/search.html?terms=SEO => http://www.bookjetty.com/search?terms=SEO
The short and sweet answer is Yes, because you will never know when your hard disk will fail.
I just got my server up last Friday (brand new server). On monday the hard disk failed, no offense to Dell, I have used Dell desktop for years and my hard disk has never failed. You just never know.
So my first setup was without RAID and I had to spend half a day in the data center recovering my server. Isn’t it wonderful if there is RAID? You just have to swap the failed hard disk with a new hard disk. And the best part is you don’t even get a down time.
So RAID it!! No question asked. Your server downtime and the time spent recovering your server is worth the extra hard disk.