All posts in Ruby on Rails

Downgrade Rubygems

First let’s list 2 truths here:

  • Rails 2.3.5 will fail with RubyGems 1.5.0 +
  • Rails 2.3.11 will fail with RubyGems 1.7.0 +

So what if you want to deploy or run an application which unfortunately still or initially written in rails 2, given the situation that latest RVM default install rubygems version 1.8.11?

It turns out to be not so painful, cause it’s as simple as just issue one command (take 1.4.2 for example):

gem update --system 1.4.2

Just like the China highway train, sometimes what you need to do is just to stop moving so fast.

ArchLinux, RVM, Ruby, Rails, Nginx, Passenger and You

没看错,就是ArchLinux,怎么,又回来了?其实我一直未曾离开…… i

好了不矫情了,let’s do business.

[Overview]
本文介绍如何在archlinux上快速搭建rails开发环境,其中有很多可能包括我个人的preferences,各位完全可以根据自行需要取舍。

[ArchLinux]
参照Arch自己的 Official Install Guide ii 安装,其实根本不用参照,整个安装wizard做的已经非常非常user friendly了,我觉得。

[RVM]
RVM 的安装依赖 git 和 curl:

$ sudo pacman -S git curl

装之:

$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

注意没有sudo,符合homebrew的philosophy,尽量不要root,何况我们还是作为development环境,rvm官网好像现在已经没有倾向性了,不过我印象中以前也是倾向于装在user的home目录。
Continue reading →

[Footnotes]
  1. 我有一个arch的liveusb,各种机子上一直保存着至少2+个arch的vm,虽然后来由于太占空间被转移到了移动硬盘,可就是一直舍不得删 []
  2. 最近老是official, official的… 你懂的 []

stdout customization

前面介绍完了deployment,接下来该轮到customization了,这个也同样重要。我目前所能想到的需要customize的地方主要有5个地方,都集中在两个文件,并没有想象中的复杂,且听我一一道来:

[page title]

Location: RAILS_ROOT/app/views/layouts/application.html.erb, line 6
<title>$ cat /dev/stdin >> /dev/stdout | tee stdout.samsonw.info</title>

change to whatever text you want.

[header title,sub-title]

Location: RAILS_ROOT/app/views/activities/index.html.erb, line 2, 3
<div id="title" class="grid_24">$ cat /dev/stdin >> /dev/stdout | tee stdout.samsonw.info</div>
<div id="sub_title" class="grid_24">Don't Panic: fatal system error, core dump file not generated ...</div>

change to whatever text you want.
Continue reading →

stdout deployment

首先值得一提的是为了支持HostMonster的fastcgi,我人为copy了几个以raild -D生成的项目结构里面的dispatch文件以及create了一个.htaccess文件,如果你不用fastcgi(通常情况下你不需要,而且也不推荐),你可以简单的删除它们(以下RAILS_ROOT是指rails app的根目录):

RAILS_ROOT/config.ru
RAILS_ROOT/public/dispatch.cgi
RAILS_ROOT/public/dispatch.fcgi
RAILS_ROOT/public/dispatch.rb
RAILS_ROOT/public/.htaccess

[Development Environment]
Assume你的os已经装好ruby,如果没有请自行google,这里不再赘述。

首先update一下rubygems,最近rubygems貌似打了鸡血,更新极其频繁… 且bug具多…如果出了问题建议rollback到1.4.2…
[Note: 由于我使用rvm,所以以下command都没有sudo,根据你的情况你可能需要加上sudo]

$ gem update --system

Continue reading →

stdout on github

stdout, aka LoserLogs or LoserStream is finally on github, check out at https://github.com/samsonw/stdout .

The code is based on rails 2.3.11 instead of rails 3, quite a surprise, isn’t it? Actually I was planning to, but after some research, it turns out my shared host provider HostMonster only support rails 2 at the time of this writing, shame on them.

It was always quite enjoyable to figure this and that out in the process of curating that site, except the deployment experiences on HostMonster. To my surprise, they’re still using Fastcgi to support rails application, again, shame on them.

Last but not least, the project is called “LoserLogs” and copyrighted by “Losers” corporation, cause I and along with some of my friends are all having the “loser” faith in our heart, this is NOT a joke

Redmine on Archlinux

[Overview]
This entry will describe a basic installation and configuration of redmine, a flexible and cross-platform project management web application, on an archlinux system.

For the official installation guide, please refer this wiki page.

[Preparation]
1. Download the latest stable release of redmine (0.8.4) from rubyforge:

$ wget http://rubyforge.org/frs/download.php/56909/redmine-0.8.4.tar.gz

2. Install ruby and ruby on rails
(Notes: rails is optional since the redmine official release we download above already include the appropriate rails version (2.1.2) in its vendor directory)

3. Make sure rubygems and rake meet the version requirement of redmine:

gem -v >= 1.3.1
rake --version >= 0.8.3

Continue reading →

Install Ruby on Rails on Archlinux

[Overview]
Here we will install ruby on rails framework on our Archlinux box. For more detail information, please refer this wiki page.

[Install ruby and rubygems]
First we need to install ruby and its package system rubygems:

$ sudo pacman -S ruby rubygems

[Install rails]
Next install rails via rubygems:

$ sudo gem install rails

gem will help us manage all the dependencies and download them automatically.

(Notes: if you execute the above command without being root (e.g. without sudo), gem will install rails in the home directory of the current user. Usually the directory is named after “.gem”, you probably need to manually add rails and rake bin directory to your PATH before you could use them, that may not be what you exactly want.)
Continue reading →