After the third week of doing the 31 Days to Build a better blog, I’m seeing the traffic and participation on my blog increasing by leaps and bounds. This last week, the traffic increase was due primarily to being featured in the Rails Envy Podcast. The idea to email Gregg Pollack about my post 9 Ways to Use Rails Metal came from step 3 in the 31 days.
You can see from the google analytics I’ve included in this post that Wednesday and Thursday I saw significant traffic. About half of that was from Rails Envy.

Traffic from Week 3 - 31 Days to Build a Better Blog
Overall, I’m extremely pleased that this system has helped so many people find what I’m offering. I’m also excited that it appears to help some people with their Ruby on Rails applications. It’s encouraging me to think about other ways I can contribute to the community. You’ll probably see posts in the upcoming weeks regarding some of the things I’ll be doing to chip in and help a few more people with Ruby on Rails.
Follow this link if you’re interested in getting 31 Days to Build a Better Blog.
blog, blogging, help, seo, traffic
A week and a half ago, I posted 9 Ways to Use Rails Metal. The fourth way I listed was “Redirecting Affiliate Links.” The basic idea is that you can set up http://mydomain.com/hosting to go to the link you were given by the hosting company you have an affiliate account with.
The first thing I did was set up a model to manage affiliate redirects.
script/generate model affiliate_redirect path:string location:string
Then I ran my migrations, to set up the database.
Then I set up a Rails Metal instance called affiliate_redirects.
script/generate metal affiliate_redirects
From there, programming Rails Metal was pretty simple. You just have to find an AffiliateRedirect with the path visited and redirect to the AffiliateRedirect’s location. Here’s the code:
1
2
3
4
5
6
7
8
9
10
11
12
| require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
class AffiliateRedirects
def self.call(env)
redirect = AffiliateRedirect.connection.select_all("SELECT * FROM affiliate_redirects WHERE path = '#{env["PATH_INFO"]}'").first
if redirect && (location = redirect["location"])
[302, {"Content-Type" => "text/html", "Location" => location}, ["You are being redirected."]]
else
[404, {"Content-Type" => "text/html"}, ["Not Found"]]
end
end
end |
This is the quick solution to the Rails action with nothing but a redirect_to.
middleware, Rails Metal, redirect, Ruby on Rails, tutorial
This is the second week I’ve been doing the 31 days to build a better blog. I’ve completed steps 3 through 7 this week and have seen an explosion of traffic on my blog. (See week one.)
Comparing the week (Saturday to Friday) of June 7th to the week of June 14th I’ve seen my visits jump from 34 to 198. That’s almost a 6 times increase in traffic. Here’s the graph from google analytics comparing the two weeks.

Traffic from June 14-20 vs June 7-13
I thought I’d see a slight uptick in traffic from following these steps, but I had over 6 times the page views and just under 6 times the visits. My new visitors was down slightly, but what that really means is that I’m getting more and more return readers to my blog.
The information in this booklet is pure gold! I’m going to get my Dad blogging for his dental practice and we’re going to apply these same principles to get his traffic and readship up just as quickly. To say I’m pleased would be a gross understatement. I’m really excited.
Look out for my report next Monday.
blog, blogging, seo
If you’re new to Ruby on Rails, you sometimes don’t know where to start with Ruby on Rails. Here are some resources that have helped me become familiar with Ruby and Ruby on Rails.
The Rails Guides have been extremely useful in explaining the different parts of Ruby on Rails. There are guides for Models, Views, Controllers, Routes, Rails Metal, Testing, etc. Most of the Guides are extremely comprehensive and have been written by experienced members of the Ruby on Rails community.
The Rails Guides are an excellent place to get started.
Ryan Bates has put together an excellent set of screencasts that help explain several concepts to programming in Ruby on Rails. The first episodes cover more basic topics. The later episodes cover gems and plugins that can be used to save you time and trouble building your Ruby on Rails application. Honestly, Ryan gets high marks in my book for the great work he’s done.
The Rails Wiki is a community generated set of documentation. The documentation here is excellent. The link above is to the “Getting Started with Ruby on Rails” page.
Do you ever have trouble remembering exactly how to put together that link_to_remote call to get the AJAX to behave exactly the way you want? Me too. That’s why I use RailsBrain.com. The interface uses AJAX to take you to the correct place in the documentation based on what you type in the search field. In other words, you usually get the answer you’re looking for before you’re done searching.
Git is the version control software of choice among Ruby and Rails developers. Github is the repository manager of choice. Most of the Ruby on Rails plugins, related gems, and even the Rails source code are stored on Github. There are also hundreds of gists that contain useful code snippets for Rubyists. If you’re looking for code samples, you’ll probably find it on Github.
Rails Tutor is in its infancy, but I highly recommend it as a place to get involved. Even if you don’t feel like you have the level of expertise to write tutorials, asking questions to flesh out the tutorials that will eventually be there will help greatly in shaping the content that new Ruby on Rails developers will be using for years to come.
Rails Envy puts out a podcast every few weeks about news and postings about Ruby on Rails. I personally have heard about plugins that I downloaded and used that same day to solve some problem I was working on. I’ve also learned several things both from their discussions and the articles they refer to. For me it was kind of the jump start from the beginner phase to the intermediate phase.
NOTE: Rails Envy has been discontinued. You can find Gregg Pollack’s new Ruby on Rails new podcast at http://ruby5.envylabs.com. You can check out the old episodes and show notes for Rails Envy at the old Rails Envy website.
The Ruby on Rails core team tracks all of their enhancements, patches, and bugs on Lighthouse. They also put their requests for new Guides and other help up on Lighthouse. If you want to know what’s coming up in the next version of Ruby on Rails or would like to get involved or make a suggestion, Lighthouse is a great place to start.
The Rails core team posts news for the community on the Rails Blog, which makes it an excellent place to go to see how they view and approach the Rails community. A lot of useful news has come out on the blog.
Feel free to add to the list in the comments for this post.
guides, Rails, Rails links, Ruby, Ruby on Rails, tutorials
I’ve had a few requests on how to access the session from Rack and Rails Metal. In the Rack environment that is passed to the call method, the session is stored at the ‘rack.session’ index. You can use this to both read from and write to the session. Here are some examples:
1
2
| session = env['rack.session']
User.find_by_id(session["user_id"]) |
1
2
| session = env['rack.session']
session["user_id"] = 1 |
rack, Rails, Rails Metal, sessions