Chen Log


Posts Tagged ‘rails

AutoLink on ruby on rails

leave a comment »

Because the AutoLink on rails has removed in rails 3.1,

so if you have to use the function you must be install other gem: 「Rinku


Before you start to install the Rinku Gem,

you must install the Xcode app and agree the license.


$ gem install rinku


  • Inserted require 'rinku' into the controller file
  • Inserted the following into the view file <% text = "Go to or email me at" %> and <%= Rinku.auto_link(text, mode=:all, link_attr=nil, skip_tags=nil) %>

key those text on the view file:

auto_link('', :all, 'target="_blank"')

Reference this url:

Written by chenagw

2014/04/21 at 00:40

Posted in Uncategorized

Tagged with , , ,

Pow port forward 設定使用方式

leave a comment »

讓 pow 的網址改連到 rails s 打開的 server

如此一來就可以披著 的網址,實際上連到 rails s -p 3000 (或其他 port) 開好的 server。

參考 pow manual – 2.1.4 Port Proxying

  1. cd ~/.pow/
  2. rm project_name 把你原本的 link 移掉
  3. echo 13001 > project_name 把想用的 port 寫到原名的檔案裡
  4. cd 到你的 project 目錄
  5. rails s -p 13001 ﹣d

加上 -d 是讓程式可以在背景執行 不用一直開著終端機的視窗

需注意如果你有多個 projects,必須自己管理網址跟 port 的對應。



Written by chenagw

2014/04/03 at 01:12

Posted in Uncategorized

Tagged with , , , ,

視覺化管理 POW 的軟體-Anvil For Mac

leave a comment »

螢幕快照 2014 04 03 00 29 31

Zero-config through Pow


Written by chenagw

2014/04/03 at 00:31

Posted in Uncategorized

Tagged with , ,

Rails ruby資料形態

leave a comment »

Here are all the Rails3 (ActiveRecord migration) datatypes:



Written by chenagw

2014/02/25 at 13:30

Posted in Uncategorized

Tagged with , ,

去掉 Float 浮點數字 後面的 0

leave a comment »

如何把 55.0 變成 55?




Written by chenagw

2013/01/19 at 00:47

Posted in Uncategorized

Tagged with ,

Ruby on Rails 字串連接方法

leave a comment »

PHP的連接是用點 “ . ”  如這樣:


echo $a.$b;

// print: ” 500apple” 

而Java的話是採用 “+” 加號。

Ruby String字串與Value變數的的連接長的比較變態一點,

$str = "#{@str1}ABCD#{@str2}CFDE"


就是引號內加上#{@變數} = “#{@變數} “

Written by chenagw

2013/01/11 at 13:46