Archive

Archive for the ‘RoR’ Category

Dynamic Title and Meta Tags using Ruby on Rails

July 9th, 2009

Here’s a quick tip on one way to do dynamic Title and/or Meta tags in your rails apps. It may not be the best way, but it works for us :-)

The problem is that you generally define your title and meta tags in your layout, but you may want to change the content in your templates depending on what page you are on. Here’s a quick way to keep it all in the view and do it using the content_for tag:

In your layout:

<title><%= (html_title = yield :html_title) ? html_title : 'My Default Title' %> - MySite.com</title>

<meta name="description" content="<%= (html_description = yield :html_description) ? html_description : 'My Default Description.' %>">

Then, in your template you can do something like this:

<% content_for :html_title, 'My Specific Page Title' %>
<% content_for :html_description, 'My Specific Page Description' %>

Hope that makes sense!

Gee RoR, Tips , , ,

Ruby on Rails

May 14th, 2009

I just started using Rails for a new project… My brother and some friends have been raving about it and how much time it would save us over our old-school PHP approach. I was never really skeptical of their claims, but the thought of learning something new for an important project is definitely scary.

However, I am now a believer in this RoR stuff. In just 4 short days, the basic framework of our new site is up and running! This timeframe even includes learning the entire framework (not to mention the Ruby language) from scratch. I’ll admit it was quite confusing at first, but once you ignore the scaffolding stuff (mostly for marketing and cool “make a blog in 15 minutes” demos) its really a piece of cake.

so yea, RoR ftw (until the next cool framework comes out :-)

Gee Projects, RoR , , ,