HowTo: Import your posts from Blogspot/Blogger

I needed to import blogspot blogs into a different system. I created a plugin that simply parses the xml file that is generated when you export your blogspot blog. Here is the link to github.

HowTo: Changing the column name in a model for validation

Sample code taken from here.

class User > ActiveRecord::Base

HUMANIZED_ATTRIBUTES = {
:email => “E-mail address”
}

def self.human_attribute_name(attr)
HUMANIZED_ATTRIBUTES[attr.to_sym] || super
end

end

HowTo: Use older gems

Now that Rails 2.1.1 is out, when you install using the gem, you get Rails 2.1.1. If you want to install an older version, like Rails 2.1.0, you need to specify the version:

sudo gem install rails –version 2.1.0

You’ll do this if you have some dependency on the older rails version. To make sure your app will run when you transfer to a different machine, freeze rails into the vendor directory:

rake rails:freeze:edge TAG=rel_2-1-0

Make sure that your environment.rb specifies the corresponding version.
Finally, you may want to create a new project using an older version of rails. You can do so by:

rails _2.1.0_ project_name

And apparently, you can use that trick for other gem-installed commands, like capistrano.

HowTo: Install Rails in Cygwin

Steps

  1. Install Cygwin
  2. Install Ruby Gems
  3. Install Rails
  4. Install the Database Adapter

Install Cygwin

Using Cygwin’s setup.exe, choose Ruby and sqlite3 under Dev. It is useful to have a version control system in place, so I recommend choosing subversion and git.

If you need MySQL connection for Rails, you need to install gcc also. You will need it to build the Cygwin version of MySQL, which is needed for the Ruby adapter.

Install Ruby Gems

Download Ruby Gems from this link. Make sure you do not have the “RUBYOPT” environment set. If you have a previous installation of Ruby you might have this set in your environment. Unset it. Unzip ruby gems, then run setup.rb.

ruby setup.rb

Install Rails

gem install rails

This will install rails, including the ri and rdoc documentation.

Install the database adapter

To install the sqlite3 adapter,

gem install sqlite3-ruby

To install MySQL support, you need to download the MySQL generic source package and build it. Extract the tarball into a temporary directory, cd to that directory, and then

./configure
make install

Building will take some time. After a successful build,

gem install mysql

If you are prompted for a choice choose the latest ruby version.

Follow

Get every new post delivered to your Inbox.