Google自訂搜尋

目前分類:Ruby on Rails (23)

瀏覽方式: 標題列表 簡短摘要

先來說說Rails 2.3中即將問世的Object#try吧

有時候我們不知道某個物件是否能夠回應某個呼叫,我們可以用object.respond_to?(method)來判斷傳回的是true還是false,因此我們可以藉由這個特性來達到我們要的目的:

f = Factory.first
puts f.category.try(:name)

只要有辦法回應就會直接呼叫name這個member function;但是別忘記了,現在還是Rails 2.2 ...

所以,我們可以自己寫一個try來用,先在Rails Project Root底下的lib新增一個try.rb,然後再config/environment.rb中新增一行:

require 'try' if Rails.version =~ /^2\.2/

這代表著如果不是2.2的版本就不要引入,當然如果你是其他版本的可以自己弄一下

然後,try.rb內寫:

class Object
  def try(method)
    return send(method) if respond_to?(method)
  end
end

存檔後重新啟動你的Rails Server即可

使用方式可參考:http://www.javaeye.com/topic/169001

這種方法有一些缺陷,所以你可以去看看要怎樣處理

 

再來說說Model.to_json吧

Rails可以用.to_json將你的資料轉成JSON輸出,不過你會發現為什麼產生的格式會有點不一樣:

Factory.all.to_json #=> [{"factory": {:.....}]

到底要怎樣才能把Model Name給隱藏呢?其實只要在你的Model內加上一段程式碼就好:

class Factory < ActiveRecord::Base
  self.include_root_in_json = false
end

這樣就能關閉了~

而且,.to_json不只可以回傳attributes,也能回傳自己寫的methods哦:

Factory.all.to_json(:methods => [:href, :src]) #=> 這樣回傳的JSON就會有{"href": '...', "src": '...'}了

如果說,不想要回傳任何一個attributes只想回傳methods該怎樣做呢?

Factory.all.to_json(:only => [], :methods => :href) #=> 傳空的陣列給:only就OK啦!

 

Person.new("CFC").say("Happy Valentines Day").to("You")
#=> CFC said Happy Valentines Day to You

Rails Fun~

下次再見啦XD

 

hechian 發表在 痞客邦 留言(2) 人氣()

Okay.. 剛剛嘗試將number_to_tw_phone給寫成Rails Plugin..發生了一點小插曲,也許是電腦秀逗吧,反正現在是成功了
就讓我紀錄一下吧

  1. 開啟Console
  2. 產生一個Rails Project
  3. 在Rails Project Root Directory中輸入script/generate plugin taiwan_helpers
  4. 此時會產生一個Plugin的資料夾在RAILS_ROOT/vendor/plugins/中,叫做taiwan_helpers
  5. 裡面有很多資料夾,我們看init.rb、libs/*這些就好

init.rb是當Rails啟動Server或Console時會先載入的一個檔案,所以要在這個檔案中將該引入與Mix-in的東西寫在裡面
所以我們先編輯init.rb

require 'taiwan_helpers'
ActionView::Base.send(:include, ActionView::Helpers::TaiwanHelper::NumberHelper)

存檔離開後,開始編輯libs/taiwan_helpers.rb
存檔離開後,啟動Rails Server,寫一段小程式看有沒有成功

接著,如果要把檔案給扔到Github上的話,只要把plugins底下的資料夾完整扔上去即可

TaiwanHelpers Github Page: http://github.com/cfc/taiwan_helpers/tree/master

hechian 發表在 痞客邦 留言(0) 人氣()

  def number_to_tw_phone(phone, cellphone=false)
    raise "Phone number error!" if phone.size < 9 || phone.size > 10 || (phone.size < 10 if cellphone)
    no = phone.split("")
    return %{#{no[0..3].join}-#{no[4..6]}-#{no[7..9]}} if cellphone
    return %{(#{no[0..2].join})#{no[3..5]}-#{no[6..8].join}} if no[0..2].join == "089" # Tai-dong
    return %{(#{no[0..1].join})#{no[2..4]}-#{no[5..8].join}} if phone.size == 9
    return %{(#{no[0..1].join})#{no[2..5]}-#{no[6..9].join}} if phone.size == 10
  end
  puts number_to_tw_phone("0987654321", true) #=> 0987-654-321
  puts number_to_tw_phone("0234567890")         #=> (02)3456-7890
  puts number_to_tw_phone("087654321")           #=> (08)765-4321
  puts number_to_tw_phone("089876543")           #=> (089)876-543 #=> 這是台東的電話

hechian 發表在 痞客邦 留言(0) 人氣()

剛剛在解決一個小Bug
用瀏覽器瀏覽某個會丟301的網站時,在Ruby或Telnet都會丟500回來
什麼鬼.. 怎麼會這樣?

其實這是因為沒有User-Agent的關係啦
有些Web Server可能會Reject一些Header中沒有User-Agent的Request
所以這時候只要在丟request時加上User-Agent這個Header即可
原本的原始碼:
response = Net::HTTP.get_response(URI.parse(uri_str))
改成:
uri = URI.parse(uri_str)
http = Net::HTTP.new(uri.host)
response = http.send_request('GET', uri.request_uri, {"User-Agent" => "Mozilla/5.0"})
這樣一來不管是301、302,還是最該死的404都沒問題啦XD

(( 因為這篇是工作上的心得,所以只好擺在Rails啦XD

hechian 發表在 痞客邦 留言(1) 人氣()

Rails 2.1推出了令人心癢癢的功能喔!讓我感覺到Rails更迷人更方便了>///<
不過我就先說兩個部份吧?

Find:
呵呵,find應該很多人都會用到吧?
這次做了點小更動呢!

假設我有一個Project Model...
  • Project.all #=> Project.find(:all)
  • Project.first #=> Project.find(:first)
接著是新增的喔!
  • Project.find(:last) #=> Project.find(:first, :order => "id DESC")
  • Project.last #=> Project.find(:last)
如何?取得資料更容易了對吧?
Named Scope:
至於這個則是從一個叫做has_finder的gem改過來的一個功能
這個功能被改過來後就改名為named_scope
假設我有一個Model叫做Article...
我想要取得所有public為true的文章,我通常會寫成
Article.find(:all, :conditions => ["public = true"])
或者是
Article.find_by_public(true)
但是透過named_scope...
# In Article.rb
class Article < ActiveRecord::Base
  named_scope :published, :conditions => { :public => true }
end

# In articles_controller.rb
class ArticlesController < ApplicationController
  def index
    @articles = Article.published
  end
end
如此即可!

hechian 發表在 痞客邦 留言(0) 人氣()

今天摸會了Git,就順便應用上了
error_messages_for大家都用過,也都知道這個不管再怎樣中文化,欄位名稱一樣都會出現給你看!
這真的是令人又愛(英語體系者愛)又恨(非英語體系者恨)的功能啊..
沒辦法,只好自己動手了...
我剛剛發了Git pull給Rails團隊,他們接受不接受我不知道,所以在這邊教大家如何自己搞定這一切
首先,先打開Rails這部份的原始碼
假設我Ruby安裝在C:\
所以路徑就是:C:\ruby\lib\ruby\gems\1.8\gems\actionpack-2.1.0\lib\action_view\helpers\active_record_helper.rb
接著,跳到error_messages_for那段程式碼,在options = params.extract_options!.symbolize_keys底下加入:fields = options[:fields].nil? ? {} : options[:fields]
然後把error_messages = objects.sum {|object| object.errors.full_messages.map {|msg| content_tag(:li, msg) } }.join這行註解,改為:
error_messages = objects.sum {|object| object.errors.full_messages.map {|msg|
              unless fields[msg.split(" ")[0].downcase.to_sym].nil?
                msg = msg.split(" ")
                field_name = msg.shift.downcase!
                msg = msg.reverse.push(fields[field_name.to_sym]).reverse.join(" ")
              end
              content_tag(:li, msg)
} }.join
存檔離開,然後這樣用:
error_messages_for(:project, :fields => {:name => "專案名稱", :summary => "專案摘要"})
而content_tag產生出來的就會是
<li>專案名稱 can't be blank</li><!-- 或其他的錯誤訊息 //-->
<li>專案摘要 can't be blank</li><!-- 或其他的錯誤訊息 //-->
很簡單吧:P?
注意,只能夠傳小寫的symbol進去
沒辦法,我功力太差了=_=|||
可以參考這邊:http://github.com/cfc/rails/commit/9e38903fd10a2de9ae9c2ca53623469f3575b43c
有任何問題歡迎提出,也可以在github上commit給我
多謝多謝:P

hechian 發表在 痞客邦 留言(0) 人氣()

想看看Rails 2.1有哪些特棒的功能嗎?
在Agile Web Development with Rails 3出來之前,難道只能夠慢慢的爬別人寫的articles嗎?
不用!在這邊提供一個免費且完整度高的Rails 2.1文件!
原文是葡萄牙文的,網址是:
http://www.nomedojogo.com/2008/06/06/o-primeiro-livro-sobre-rails-21-e-brasileiro/

如果沒興趣或看不懂葡萄牙文的,可以看看英文版:http://www.nomedojogo.com/2008/06/09/new-free-book-ruby-on-rails-21-whats-new/

By the way, Rails 2.1更方便了呢!!

Update(2008-06-23):
大陸的Iceskysl前輩前些日子號召了一些人進行中文版的翻譯
翻譯文章已經完成,網址是:http://sites.google.com/site/iceskysl/acticles/ruby-on-rails-21%E6%96%B0%E7%89%B9%E6%80%A7%E4%BB%8B%E7%BB%8D/introduction
感謝Iceskysl與其他的前輩們:D

hechian 發表在 痞客邦 留言(0) 人氣()

剛剛在更新Rubygems與Rails 2.0
Rubygems安裝好了,可是Rails 2.0裝不起來
錯誤訊息(只貼關鍵)
Rails 2.0 SSL is not installed on this system
OK... 該怎辦呢?
先說明一下我的系統環境:
  • Ubuntu (版本不拘)
  • Ruby 1.8 (自己Compile的)
  • RubyGems 0.9.5 (嗯,剛剛更新好的)
我之前好像有記錄過透過apt-get安裝與自己編譯的ruby,兩種的預設目錄都不一樣
apt-get安裝的預設目錄是
/usr/lib/ruby
自己編譯的則是在
/usr/local/lib/ruby
差別就在這邊了
所以我們可以用網路上所教的方式來解決,並且動點手腳來完成
sudo apt-get install libopenssl-ruby1.8
cp -r /usr/lib/ruby/1.8/openssl* /usr/local/lib/ruby/1.8/
cp /usr/lib/ruby/1.8/i486-linux/openssl.so /usr/local/lib/ruby/1.8/i686-linux
這樣就可以更新了!

hechian 發表在 痞客邦 留言(0) 人氣()

太久沒有寫文章了.. 最近接到一個案子.. 剛好讓我重溫Select的使用方法..
嗯.. 結果卡在multiple,不知道是我太想睡還是怎樣.. 居然傻了..
跑去#rubyonrails問,一位名為carpet_the_walls的網友給了我他寫的文章,網址是:
http://shiningthrough.co.uk/Select+helper+methods+in+Ruby+on+Rails
在此先謝謝carpet_the_walls (Thank you, carpet_the_walls)

來做個Memo.. 不然又忘記了..
在Rails中真的有一堆Select helper可以用.. 不只carpet_the_walls混淆,連我也模糊不清!
常見的有三個..
select, select_tag, collection_select(其餘的什麼select_date那些不談)
我們先來看看一個基本的下拉式選單骨架
<select name="selection">
  <option value="1">Opt1</option>
  <option value="2">Opt2</option>
</select>
在一個下拉式選單中,有一些是必備的資訊,像是"name"、"value"與"text"三個,在回傳資訊給Server時,"name"將是接收資訊用的,而"value"會傳回被選的值,而"text"則是使用者會看到的字,依上面的例子來講,Opt1、Opt2這兩個就是屬於"text"

開始講講那三種Select helper

select:
  select(object, method, choices, options = {}, html_options = {})
  在ActionView::Helpers::FormOptionsHelper中定義

  • object是一個實體化變數,這裡很明顯的就是要擺上model物件嘛!
  • method則是object的一個屬性,也是資料表中的對應欄位
  • choices就是要被選的選項,可以是陣列或者是雜湊(Hash)
  • options與html_options則是一些選項
在這邊來舉個例子吧
<%= select("project", "teacher_id", @teachers.collect{|t| [t.name, t.id]}, { :include_blank => false }) %>
<%= select("project", "student_id", {"CFC" => '1', "EF" => '2'}) %>
第一個例子中,@teachers在Controller是這樣的
@teachers = Teacher.find(:all, :select => 'id, name')

select_tag:
  select_tag(name, option_tags = nil, options = {})
  在ActionView::Helpers::FormTagHelper中定義

如果你很喜歡手動打option的話.. 那用select_tag準沒錯啦!
在select_tag中,name將會是params所接收值所用的鍵
直接看範例
<%= select_tag 'user', "<option>CFC</option>" %>
這時在Controller中將會用params[:user]來接收傳過來的值
但是select_tag也可以搭配options_for_select或者options_from_collection_for_select一起使用.. 來看一個範例吧
<%= select_tag('sid[]', options_from_collection_for_select(@students, 'id', 'name'), :multiple => true)%>
因為加上了:multiple,所以可以接受多值選擇,這時在Controller接收到的sid將會是一個陣列,這也是我所卡住的地方.. (( 真丟臉

collection_select:
  collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {})
  在ActionView::Helpers::FormOptionsHelper中定義

如果資料來源是從資料庫來的話,可以使用這個來做下拉式選單。
這個Object不用我說,就是你的model
method呢?當然就是欄位啦
其實嚴格說起來,這只是select+options_from_collection_for_select的組合啦!
範例:
<%= collection_select(:payment, :id, @payments, :id, :name, options ={:prompt => "-Select a continent"}, :class =>"payment") %>

再次謝謝原作者carpet_the_walls:)

hechian 發表在 痞客邦 留言(0) 人氣()

請在model內加入:
def self.find_by_randomize
  ids = self.find(:all, :select => [id])
  self.find(ids[rand(ids.size)]["id"].to_i)
end
這樣一來,就可以取亂數選取資料了!

請參考這篇:為你的 Active Record 做出多采多姿的 find

當然囉.. thegiive那個就是我修改的範本:P

hechian 發表在 痞客邦 留言(0) 人氣()

  • Mar 26 Mon 2007 23:43
  • 置頂 HAML

最近開始接觸HAML
在Rails中,預設使用ERb來當作模板描述語言,可是這樣寫個人認為非常醜也非常累...
而之前看到HAML時感覺到那東西似乎沒有太大的可用性,難道要Designer也學Ruby嗎?
不過後來我想通了..

架構這部分可以給Coder作,Designer乖乖設計CSS就夠了..
來看看底下這個Sample吧:

這是rhtml

  <div id='content'>
    <div class='left column'>
      <h2>Welcome to our site!</h2>
      <p>
        <%= print_information %>
      </p>
    </div>
    <div class="right column">
      <%= render :partial => "sidebar" %>
    </div>
  </div>

這是HAML

  #content
    .left.column
      %h2 Welcome to our site!
      %p= print_information
    .right.column= render :partial => "sidebar"

看!少了多少行?
可以讓開發速度變快耶= v =...
最主要的是,看起來也比較美觀了!

參考:
http://haml.hamptoncatlin.com/tutorial/
http://haml.hamptoncatlin.com/docs/

hechian 發表在 痞客邦 留言(0) 人氣()

用過Flickr嗎?
如果你有Flickr相簿,應該對於修改照片標題、說明的方式記憶猶新吧?
那種就叫做 In Place Editing
在Rails中,要實做這種技術並不難,因為本身就內建這個功能
不過到了Rails 2.0將會把這個從內建移除變成Plugins形勢存在
可以參考這篇:In-plcae-editing by Rails
不過我在這裡重新說明一次使用方式
如果有<%= javascript_include_tag :defaults %>的話,那只剩下兩個步驟:

Controller:
  class ObjectController < ApplicationController
    in_place_edit_for :object, :method
  end

View:
  <%= in_place_editor_field :object, :method %>
這樣就可以建立起最基本的InPlaceEditing欄位
可是最基本的都是英文,因此Rails也提供了修改參數,可以參考 這篇
in_place_editor_field欄位有四個參數:
  in_place_editor_field(object, method, tag_options = {}, in_place_editor_options = {})
而修改的部分則是放在第四個參數;假設我要修改:saving_text:
  <%= in_place_editor_field(:object, :method, {}, {:saving_text => "儲存中..."} %>
改好後記得重新整理頁面!

另外,如果要建立多個欄位的話,必須用這種方法:

  class ObjectController < ApplicationController
    in_place_edit_for :object, :method1
    in_place_edit_for :object, :method2
    in_place_edit_for :object, :method3
  end

這樣寫超麻煩的!因此可以這樣:
  class ObjectController < ApplicationController
    %w"method1 method2 method3".each do |m|
      in_place_edit_for :object, m.to_sym
    end
end

這樣未來在新增刪除上都會很方便!

hechian 發表在 痞客邦 留言(0) 人氣()

最近將Rails升級到1.2的版本
在開發一個案子時看到Log寫的一些不被建議的寫法
現在一一記下:

=====分隔線=====

原本:has_many :line_items, :dependent => true
建議:has_many :line_items, :dependent => :destroy

原本:start_form_tag()
建議:form_tag()

原本:end_form_tag()
建議:

===============

參考資訊
http://www.rubyonrails.org/deprecation
http://leethal.stikipad.com/rails/show/1.2.1+Deprecations

hechian 發表在 痞客邦 留言(0) 人氣()

Rails在你用scaffold建立時,會幫你建立分頁
但是這個分頁感覺沒啥用...

in your controller...

def list
  @user_pages, @user = paginate(:user, :per_page => 10)
end

In fact...
非常不堪用=  =
一般來說,我有10筆資料,per_page設定成2
應該要分成五頁(這有做到),然後照順序排

如果說,我在list.rhtml內寫著

<% @user.reverse.each do |x| %>
  <%= @user.username %>
 

  <%= pagination_links(@user) %>
<% end %>

errr.. I'm sorry.. 失敗!

怎麼說呢?分頁的確是產生了.. but!!!
10
9
8
7
6
5
4
3
2
1
這是原本的順序
第一頁要有10跟9
第二頁要有8跟7
可是卻沒有..
變成第一頁2跟1
第二頁4跟3..

是我作錯了還是怎樣?

======
補充:


剛想到,或許@user這邊.. 必須要reverse一下再傳?
也許這樣就可以了...

不過昨晚沒有睡.. 整晚在寫Private Message System..
算了.. 先去躺一下="=

養肝千日,爆在一時...

hechian 發表在 痞客邦 留言(4) 人氣()

呵..
編輯routes.rb
增加一行:

map.connect '', :controller => "ctrl_name"

存檔離開後,把public底下的index.html刪除或者改名即可

Take a note :P

hechian 發表在 痞客邦 留言(0) 人氣()

在Rails,如果你想要使用自訂的Primary Key Name(主鍵)的話(如果你用Migrate產生,預設就會建立一個叫作id的主鍵)可以使用set_primary_key
set_primary_key好像還要搭配set_table_name使用,不然會出錯!
因為我在作補習班網站的案子時,僅僅加入set_primary_key就出錯,加上set_table_name才正常,因此我想set_primary_key一定要有set_table_name的輔助吧?不過反之我想應該不同!
請在Model裏面編輯
set_table_name “tbl_name”
set_primary_key “pk_name
但是請注意!如果自訂Primary Key的話,在編輯的欄位內請不要讓那個欄位可以編輯!假設我…
set_table_name "people"
set_primary_key "uid"
此時就別讓uid可以編輯,像是出現:
<%= text_field "person", "uid" %>
這樣會產生錯誤!
詳情可以參考:
Agile Web Development with Rails書中第14章第三節的部份,雖然繼續使用uid還是可以的,但是會比較麻煩點!
而該節最後一句話:When you need to set the primary key, use id. At all other times, use the actual column
感謝China on Rails群組中的darren.hoo!
相關討論請看:
Ruby on Rails on Google Groups

hechian 發表在 痞客邦 留言(0) 人氣()

網址在家族

預計新增基本功能:
* 身份審核功能 -- 自己只能更新自己的資料
* 備份功能 -- 以防資料毀損
* 友善列印 -- 用印表機印出來
* 下載通訊錄 -- 下載存成Excel檔

預計新增額外功能:
* 即時通上線狀態顯示 -- 可以觀看是否在線上
* 無名連結 -- 連結到無名相簿

個人想要新增功能:
* 聊天室 -- 天讚每次開即時通會客室自己都會當掉
* 公告事項 -- 也是可以不必要的..

Wish list...
請貼在家族討論區,謝謝

hechian 發表在 痞客邦 留言(0) 人氣()

昨晚在逛Railscn時看到AJAX Scaffold
當時在想:”AJAX腳手架?不會吧… ” 看過Rails的scaffold後感覺到真的很恐怖
因此就在想… 該不會真的這麼棒?只要幾個步驟就可以搞定了嗎?
點進去後,發現只要五個步驟就可以搞定… “嘿!挺有趣的說!”
網址是:

我簡單的寫個步驟好了…

1. 當然是先建立一個Rails專案拉!記得要去設定config/database.yml
  • rails ajax
2. 產生一個model
  • script/generate model member
3. 編輯db/migrate/001_create_members.rb
  • 請根據下面去修改
    class CreateMembers < ActiveRecord::Migration
    def self.up
    create_ table :members do |t|
    t.column :name, :string
    t.column :email, :string
    t.column :address, :string
    end
    end
    def self.down
    drop table :members
    end
    end
4. 好!開始rake migrate
  • rake migrate
5. 產生AJAX Scaffold
  • script/generate ajax_scaffold member

好拉!去看看吧!

script/server -p 3000

http://localhost:3000/members

哈哈!
這邊可以看到範例

 

hechian 發表在 痞客邦 留言(0) 人氣()

由於我是Ubuntu Linux,屬於Debian派系的(因此,如果你是Debian使用者,這篇也可以看)
所以我們在安裝東西前,最好把Ruby的所有東西都裝好
還有,Ubuntu的使用者,請記住
$ sudo apt-get install build-essential
↑一定得作

$ sudo apt-get install ruby ruby1.8 ri rdoc
$ cd rubygems; sudo ruby setup.rb
$ sudo gem update;sudo gem install -y rails;sudo gem install -y mongrel

接著,Apache2裝好後

參考此篇文章設定
http://schwuk.com/articles/2006/06/13/hosting-rails-applications-with-mongrel-apache-2-mod_proxy-on-debian-stable

首先,將mongrel啟動

$ cd my_app/
$ mongrel_rails start -d
$ a2emod proxy

設定一下Rails的VirtualHost or Proxy

ProxyPass / http://cfc.zuso.tw:3000/
ProxyPassReverse / http://cfc.zuso.tw:3000/

好了之後設定/etc/apache2/mods-available/proxy.conf


  Order deny,allow
  Allow from all


存檔離開後就重新啟動Apache2

hechian 發表在 痞客邦 留言(0) 人氣()

感謝AnW提供這樣的一個方法
以下是他寫給我的信件內容:

正在試一個方法,  Apache 2.2 + WEBrick/Mongrel

HOW
1. 利用 mod_proxy*
2. 交給 WEBrick 或 Mongrel(若要快的話),
很簡單, 應該也穩

方法:
1. httpd.conf
LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so

#ruby on rails
ProxyRequests On
ProxyVia On


  Order deny,allow
  Deny from all
  Allow from localhost

ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/

2. 啟動
$ cd myapp
$ ruby script/server

3. visit http://localhost/ror

4. 我還沒很完整測, cfc 你拿留言板測一下, 大家討論看看...
支持 Mongrel 好好發展!

參考自 http://blog.innerewut.de/

 
以下是我的實作:
由於我的是Debian Linux
唔.. Apache的Modules都放在:
/usr/lib/apache2/modules/
底下,因此,在LoadModule那邊的寫法要更改!
#改成以下兩行
LoadModule mod_proxy /usr/lib/apache2/modules/mod_proxy.so
LoadModule mod_proxy_http /usr/lib/apache2/modules/mod_proxy_http.so

好,開始吧!
vim /etc/apache2/apache2.conf

#Load Modules
LoadModule mod_proxy /usr/lib/apache2/modules/mod_proxy.so
LoadModule mod_proxy_http /usr/lib/apache2/modules/mod_proxy_http.so

#Ruby on rails
#Turn on Proxy
ProxyRequests On
ProxyVia On

#Settings

  Order allow, deny
  allow from all
  deny from all

ProxyPass / http://cfc.zuso.tw:3001/
ProxyPassReverse / http://cfc.zuso.tw:3001/

存檔離開
我說明一下我的主機情形:
現在,我的Rails App的Controller叫做gbook,Webrick開3001 Port
因此,當提出要求存取gbook時,proxy會轉到cfc.zuso.tw:3001/gbook
webrick收到,就開始Rails了..



hechian 發表在 痞客邦 留言(0) 人氣()

1 2