在DreamHost上部署Rails程序
发表于:2007年06月07日  分类:Rails  添加评论  1,592 次浏览 

子域名labs.nanshapo.com,用ssh登录到系统。

[rollo]$ pwd
/home/liubin/labs.nanshapo.com
[rollo]$ rails front
/usr/bin/rails:17:Warning: require_gem is obsolete. Use gem instead.
create
create app/controllers
create app/helpers
.....................
create log/server.log
create log/production.log
create log/development.log
create log/test.log
[rollo]$
[rollo]$ cp front/public/.htaccess ./
[rollo]$ vi .htaccess

对.htaccess只有两个小小的修正:
RewriteRule ^(.*)$ front/public/dispatch.fcgi [QSA,L]
即将cgi改为fcgi,同时加入路径front/public/等。

创建一个控制器和2个简单的action

[rollo]$ ruby script/generate controller Main index test
exists app/controllers/
exists app/helpers/
create app/views/main
exists test/functional/
create app/controllers/main_controller.rb
create test/functional/main_controller_test.rb
create app/helpers/main_helper.rb
create app/views/main/index.rhtml
create app/views/main/test.rhtml
[rollo]$

修改router

[rollo]$ vi config/routes.rb

在适当的地方加入(或者将那个注释掉的改一下)
map.connect '',:controller=>"main"

这时候看了一下http://labs.nanshapo.com/
显示如下
Main#index
Find me in app/views/main/index.rhtml

再看看test action

http://labs.nanshapo.com/Main/test

显示
Main#test
Find me in app/views/main/test.rhtml

修改一下程序

  1. class MainController < ApplicationController
  2.  
  3.   def index
  4.     @cip = request.remote_ip
  5.   end
  6.  
  7.   def test
  8.     @refer = headers["Referer"]
  9.   end
  10. end
  1. #index.rhtml
  2. hello <%=@cip%>
  3. <br>
  4. <%=url_for :action=>"test"%>
  5. <br>
  6. <%= link_to "Go to test", :action => "test" %>

不过link_to和url_for产生的url都是/front/public/main/test 。明天看看怎么改吧。

固定链接: http://liubin.nanshapo.com/2007/06/07/%e5%9c%a8dreamhost%e4%b8%8a%e9%83%a8%e7%bd%b2rails%e7%a8%8b%e5%ba%8f/ | 其实我是一个程序员
【上篇】
【下篇】

报歉!评论已关闭.