<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Radio 21 Gram</title>
	<link>http://www.radio21g.com/blog</link>
	<description>Radio21g.com official blog</description>
	<pubDate>Thu, 10 Jul 2008 16:40:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>
	<language>en</language>
			<item>
		<title>Rails Migration: enable rollback</title>
		<link>http://www.radio21g.com/blog/2008/07/10/rails-migration-enable-rollback/</link>
		<comments>http://www.radio21g.com/blog/2008/07/10/rails-migration-enable-rollback/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 16:35:32 +0000</pubDate>
		<dc:creator>roosevelt</dc:creator>
		
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.radio21g.com/blog/2008/07/10/rails-migration-enable-rollback/</guid>
		<description><![CDATA[With Rails Migration, you can easily add or update your DB schema with a command &#8220;rake db:migrate&#8220;.
But if you just realize that you gave the wrong datatype for your new column or you want to rename your new column, you may want to rollback to your previous schema version and re-run the update again. To [...]]]></description>
			<content:encoded><![CDATA[<p>With Rails Migration, you can easily add or update your DB schema with a command &#8220;<strong>rake db:migrate</strong>&#8220;.</p>
<p>But if you just realize that you gave the wrong datatype for your new column or you want to rename your new column, you may want to rollback to your previous schema version and re-run the update again. To rollback to your previous schema, you need issue the command:</p>
<p><strong>    # <code>rake db:migrate VERSION=<em>prev_version</em></code></strong></p>
<p>where <em>prev_version</em> is the last version number of your DB schema, you need to find it out either by checking your last db migration files name or check the SCHEMA table in your DB. This apparently is not very convinient.</p>
<p>To be a little smarter, try putting the following code into a file <em>called &lt;RAILS_HOME&gt;/lib/tasks/rollback.task</em>, this will let you achieve the above by just issuing a single command like:</p>
<p><strong>    # rake db:rollback </strong></p>
<p>additionally, to check the current DB schema version:</p>
<p><strong>    # rake db:current</strong></p>
<pre name="code" class="ruby">namespace :db do
  desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n'
  task :rollback =&gt; :environment do
    step = ENV['STEP'] ? ENV['STEP'].to_i : 1
    version = ActiveRecord::Migrator.current_version - step
    ActiveRecord::Migrator.migrate('db/migrate/', version)
  end
end

namespace :db do
  desc 'get current schema version'
  task :current =&gt; :environment do
    puts ActiveRecord::Migrator.current_version
  end
end</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.radio21g.com/blog/2008/07/10/rails-migration-enable-rollback/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Use Unicode in Ruby on Rails Application</title>
		<link>http://www.radio21g.com/blog/2008/05/05/use-unicode-in-mysql-database-for-ruby-on-rails/</link>
		<comments>http://www.radio21g.com/blog/2008/05/05/use-unicode-in-mysql-database-for-ruby-on-rails/#comments</comments>
		<pubDate>Mon, 05 May 2008 17:13:50 +0000</pubDate>
		<dc:creator>roosevelt</dc:creator>
		
		<category><![CDATA[rails]]></category>

		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.radio21g.com/blog/?p=4</guid>
		<description><![CDATA[When creating a new web application, it&#8217;s a good practice to use Unicode encoding in your database even when your content are all in English. Radio21g.com is created with UTF-8 from day 1 with following 2 steps:

To make sure  your  database  is using Unicode to store the text data, make sure you [...]]]></description>
			<content:encoded><![CDATA[<p>When creating a new web application, it&#8217;s a good practice to use Unicode encoding in your database even when your content are all in English. <a href="http://www.google.com" title="radio21g.com" target="_blank">Radio21g.com</a> is created with UTF-8 from day 1 with following 2 steps:</p>
<ol>
<li>To make sure  your  database  is using Unicode to store the text data, make sure you create the database with encoding specified:
<pre name="code" class="sql">create database radio21g character set utf8;</pre>
</li>
<li>After the database ready, you also need to tell the rails Mysql adapter to save and retrieve the data as unicode. You do this in the last line of the /config/database.yml:</li>
</ol>
<blockquote>
<pre name="code" class="sql">
development:
  adapter: mysql
  database: database
  username: root
  password:
  host: localhost
  encoding: utf8</pre>
</blockquote>
<blockquote></blockquote>
<p>In addition to database related settings, your web page (RHTML) should also display the text and submit the user input in UTF-8. To achieve that, you need to:</p>
<ol>
<li> Specified the &#8220;charset=UTF-8&#8243; in your HTML head:
<pre name="code" class="html">&lt;meta http-equiv="content-type" content="text/html; charset=UTF-8" /&gt;</pre>
</li>
<li>Set the Content-Type header in the rails @headers object of each request. Usually this is done in the /app/controller/applicaiton.rb with a filter:
<pre name="code" class="ruby">
    class ApplicationController &lt; ActionController::Base end
        before_filter :set_charset

        def set_charset
            @headers["Content-Type"] = "text/html; charset=utf-8"
        end

    end</pre>
<p>For Rails 2.0 and above, this step is not needed anymore as UTF-8 is the default setting in the @headers.
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.radio21g.com/blog/2008/05/05/use-unicode-in-mysql-database-for-ruby-on-rails/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Radio21g.com says Hello world!</title>
		<link>http://www.radio21g.com/blog/2007/07/19/hello-world/</link>
		<comments>http://www.radio21g.com/blog/2007/07/19/hello-world/#comments</comments>
		<pubDate>Thu, 19 Jul 2007 16:22:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[news]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Welcome to the official blog of radio21g.com.   
radio21g  is a community where users can create regular digests (we call &#8216;Channel&#8216;) for the news sources they familiar with. Other users, by subscribing to these channels, can save their time and read more of what really worth reading on their favorite news sources.
Feel frustrated [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to the official blog of <a href="http://www.radio21g.com" title="radio21g.com">radio21g.com</a>.   <a href="http://www.radio21g.com" title="radio21g.com" class="no-dash"><img src="http://www.radio21g.com/images/hlogo.gif" title="radio21g logo" alt="radio21g logo" height="35" width="110" /></a></p>
<p><a href="http://www.radio21g.com" title="radio21g.com">radio21g</a>  is a community where users can create regular digests (we call &#8216;<a href="http://www.radio21g.com/channels" title="channels" target="_blank">Channel</a>&#8216;) for the news sources they familiar with. Other users, by subscribing to these <a href="http://www.radio21g.com/channels" title="channels" target="_blank">channels</a>, can save their time and read more of what really worth reading on their favorite news sources.</p>
<p>Feel frustrated every morning when you open your RSS reader only to find there are 200+ fresh news items waiting for you? Imagine to have others to read through those feeds for you in advance and pick out only those that are of high quality and really worth your time. Thus, instead of going through all 200+ news items, you only need to read 10 - 15 stories that worth reading. You can use the saved time to read more widely or concentrate on your other work to please your boss.</p>
<p>This is the place where we document those little steps the <a href="http://www.radio21g.com" title="radio21g.com" target="_blank">radio21g.com</a> take on her way of growing bigger and stronger.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.radio21g.com/blog/2007/07/19/hello-world/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
