Archive | Rails RSS feed for this section

Install — Phusion Passenger

Phusion Passenger,亦即mod_rails,可用于Apache或nginx的快速部署模块。

安装


gem install passenger
passenger-install-apache2-module

虚拟主机配置


<Virtualhost *:80>
ServerName hostname
DocumentRoot /home/muzik/workspace/appname/public/
RailsEnv development #默认为production
<Directory /home/muzik/workspace/appname/public/>
Options ExecCGI FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
ErrorLog /home/muzik/workspace/appname/log/error.log
CustomLog /home/muzik/workspace/appname/log/access.log combined
</Virtualhost>

出现的问题

Missing the Rails 2.3.4 gem.

完整的错误提示:

Missing the Rails 2.3.4 gem. Please `gem install -v=2.3.4 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

事实上,需要的gem都是安装过的,只是它找不到罢了。在config/environment.rb里添加上就好了:


ENV['GEM_PATH'] = "/home/muzik/.gem/ruby/1.8:#{ENV['GEM_PATH']}"

 

rails常用插件

 

AuthLogic Plugin

  1. Authlogic
  2. Authlogic Example App


script/plugin install git://github.com/binarylogic/authlogic.git

简洁易用的分页插件Will Paginate

  1. will_paginate
  2. rdoc


gem sources -a http://gemcutter.org
gem install will_paginate
#or
script/plugin install git://github.com/mislav/will_paginate.git

用法


require "will_paginate"
@posts = Post.paginate :page =>params[:page], :order => 'created_at DESC'
<%= will_paginate @posts %>