顯示具有 Ruby on Rails 標籤的文章。 顯示所有文章
顯示具有 Ruby on Rails 標籤的文章。 顯示所有文章

2015年1月19日 星期一

My troubleshooting of Rails on Windows

前言

Windows上安裝Linux VM, 直接在Linux環境開發Rails網站程式(我的Rails環境安裝(CentOS)), 除了在建立環境時, 可以熟悉Linux Server上的安裝設定外, 在開發完成後, 也可以直接建立正式的Web Server環境(e.g. use nginx)來做正式環境的測試.

這樣的做法, 便是在模擬Production Server的狀況, 在建立環境以及開發過程中, 就能及早發現可能會遇到的問題, 進而及早解決.

雖然我已經是這麼做了, 但有時不免會覺得等個VM開啟, 之後在console環境下寫程式, 有點累...XP...所以...我終於決定在要Windows環境上建立個Rails開發環境啦~~~

在Windows安裝Rails開發環境並不難, 安裝檔下載完後, 點一點下一步就能完成了...
本來預想, Linux上開發好的專案目錄整個載回Windows後, 下指令bundle install之後rails s就能測試網站了...但...果然發生了一連串的問題!!!
問題多半在於gem的安裝(未安裝或版本跟Linux環境略有差異)以及其相關的設定...

將問題以及解決方法筆記起來幫助自己記憶, 也分享給遇到相同狀況的人~~:)


Troubleshooting

1. bundle install時, 出現Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
這錯誤多半是在compile某段程式時, 找不到相依的程式(gem), 所以就報錯啦...
報錯的stack trace丫里丫雜很長, 好加在最後它都會說哪個gem出了什麼問題, 按照指示尋找蛛絲馬跡, 就有機會解決問題啦!

案例一
明明有libv8的gem, 怎麼報錯了呢
D:/RailsInstaller/Ruby2.1.0/bin/ruby.exe extconf.rb
creating Makefile
系統找不到指定的路徑。
系統找不到指定的路徑。
系統找不到指定的路徑。
D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.3/ext/libv8/builder.rb:58:in `setup_python!': libv8 requires python 2 to be installed in order to build, but it is currently not available (RuntimeError)
        from D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.3/ext/libv8/builder.rb:42:in `block in build_libv8!'
...
Gem files will remain installed in D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.3 for inspection.
Results logged to D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/libv8-3.16.14.3/gem_make.out
An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before bundling.
解決方法, 就在於後面的option設定
# gem install libv8 -v '3.16.14.3' -- --with-system-v8
相關說明可參考此連結: https://github.com/cowboyd/libv8#bring-your-own-v8

案例二
用到mysql的功能, 但缺了什麼設定呢
D:/RailsInstaller/Ruby2.1.0/bin/ruby.exe extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
...
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.  Check the mkmf.log file for more details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=D:/RailsInstaller/Ruby2.1.0/bin/ruby
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
...
Gem files will remain installed in D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/mysql2-0.3.16 for inspection.
Results logged to D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/mysql2-0.3.16/gem_make.out
An error occurred while installing mysql2 (0.3.16), and Bundler cannot continue.

Make sure that `gem install mysql2 -v '0.3.16'` succeeds before bundling.
解決方法, 就在於安裝mysql2的套件, 需設定開發環境上的MySQL Server路徑, 讓其可成功的建置並安裝
# gem install mysql2 -v '0.3.16' -- '--with-mysql-dir="MySQL Server installed path" --with-mysql-lib="MySQL Server installed path\lib" --with-mysql-include="MySQL Server installed path\include"'

案例三
therubyracer你怎麼了???
D:/RailsInstaller/Ruby2.1.0/bin/ruby.exe extconf.rb
checking for main() in -lpthread... no
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.  Check the mkmf.log file for more details.  You may need configuration options.
...
D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.3/ext/libv8/location.rb:50:in `configure': 
You have chosen to use the version of V8 found on your system (Libv8::Location::System::NotFoundError) and *not* the one that is bundle with the libv8 rubygem. 
However, it could not be located. please make sure you have a version of v8 that is compatible with 3.16.14.3 installed. 
You may need to special --with-v8-dir options if it is in a non-standard location
...
Gem files will remain installed in D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/therubyracer-0.12.1 for inspection.
Results logged to D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/therubyracer-0.12.1/gem_make.out
An error occurred while installing therubyracer (0.12.1), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.12.1'` succeeds before bundling.
解決方法, 不使用therubyracer
在Gemfile裡, therubyracer預設是被註解起來的...會被註解起來, 一定有其道理, 所以不要隨便把他打開呀XD
若要使用JavaScript runtime, 可以安裝其它的runtime, e.g. Node.js
# sudo yum install nodejs -y
相關說明可參考此連結: http://stackoverflow.com/questions/18687575/why-is-the-gem-therubyracer-commented-out-by-default-in-gemfile


2. rails s後, 出現找不到什麼東西的狀況...
比如會看到的錯誤有: 找不到指定的模組, cannot load such file...etc.
就如報錯所說, 就是找不到那些東西, 所以把那些東西補齊就能解決問題啦~XD

案例一
找不到libmysql.dll
D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/mysql2-0.3.16/lib/mysql2.rb:8:in `require': 126: 找不到指定的模組。   - D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/mysql2-0.3.16/mysql2/mysql2.so (LoadError)
        from D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/mysql2-0.3.16/lib/mysql2.rb:8:in `'
...
解決方法, 將MySQL Server目錄裡的libmysql.dll複製到Ruby\bin的目錄下
相關說明可參考此連結: https://github.com/brianmario/mysql2#windows

案例二
tzinfo找不到data(TZInfo::DataSourceNotFound)
D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/tzinfo-1.2.2/lib/tzinfo/dat
a_source.rb:182:in `rescue in create_default_data_source': No source of timezone
 data could be found. (TZInfo::DataSourceNotFound)
Please refer to http://tzinfo.github.io/datasourcenotfound for help resolving th
is error.
        from D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/tzinfo-1.2.2/l
ib/tzinfo/data_source.rb:179:in `create_default_data_source'
        from D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/tzinfo-1.2.2/l
ib/tzinfo/data_source.rb:40:in `block in get'
...
解決方法, Gemfile加入下列gem
gem 'tzinfo-data'
細節設定請參考此連結: https://putshello.wordpress.com/2014/01/06/tzinfodatasourcenotfound-no-timezone-data-source-could-be-found/

案例三
找不到相依的bcrypt
D:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require': cannot load such file -- bcrypt_ext (LoadError)
...
解決方法, 升級bcrypt至3.1.9
# bundle update bcrypt
在Gemfile, 設定bcrypt使用3.1.9的版本
gem 'bcrypt', '~> 3.1.9'
相關說明可參考此連結: https://github.com/codahale/bcrypt-ruby/issues/102


3. Could not find a valid gem 'xxx' or Could not find gem 'xxx' ...
表示gem沒下載或安裝成功, 範例錯誤如下
ERROR:  Could not find a valid gem 'bootstrap-sass' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/latest_specs.4.8.gz)
...
Could not find gem 'bootstrap-sass (~> 3.3.1) x86-mingw32' in the gems available on this machine.
...
解決方法, 增加一個可以下載的gem source後, 下載gem
# gem source -a http://rubygems.org/
# gem install bootstrap-sass


最後, 相依的gem都無誤後, 我要把專案的db建立起來(not migrate)
# bundle exec rake db:reset
or
# bundle exec rake db:drop
# bundle exec rake db:create
# bundle exec rake db:schema:load
# bundle exec rake db:seed
再次rails s, 並實際連到網頁, 確認是否還有類似的問題, 再去解決囉~~~


4. 網頁實際執行, 用到某些套件功能時, 出錯了...Orz
通常是某些gem的版本在windows上不支援...只能在報錯中尋找蛛絲馬跡了...

案例一
TypeError: 物件不支援此屬性或方法
用中文, google大神查不到資料呢XD, 用英文, TypeError: Object doesn't support this property or method, 就查到相關解決方案了...
解決方法, Gemfile加入下列gem
gem 'coffee-script-source', '1.8.0'
接下來執行
bundle update coffee-script-source
相關說明可參考此連結: http://stackoverflow.com/questions/28312460/object-doesnt-support-this-property-or-method-rails-windows-64bit


2014年9月22日 星期一

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

使用open uri執行https的網址, 發生了SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed的錯誤!!!

google找了一些solution:
1. http://stackoverflow.com/questions/5711190/how-to-get-rid-of-opensslsslsslerror
2. http://stackoverflow.com/questions/10728436/opensslsslsslerror-ssl-connect-returned-1-errno-0-state-sslv3-read-server-c
3. http://jimneath.org/2011/10/19/ruby-ssl-certificate-verify-failed.html

主要是嘗試了config/initializers/fix_ssl.rb的方法(參照第3個連結):
require 'open-uri'
require 'net/https'

module Net
  class HTTP
    alias_method :original_use_ssl=, :use_ssl=
    
    def use_ssl=(flag)
      self.ca_file = Rails.root.join('lib/ca-bundle.crt')
      self.verify_mode = OpenSSL::SSL::VERIFY_PEER
      self.original_use_ssl = flag
    end
  end
end
但問題仍然無法解決...


重新正視問題, 發現有SSL憑證的網址(ex: https://www.facebook.com/), 不會出現錯誤; 沒有SSL憑證的網址, 在browser也會出現憑證錯誤或未受信任(不安全)的連線等等的警告頁面, 這類網址才會出現錯誤~~問題可以釐清了!!

一開始找的solution方向比較偏向certification authority certificates(CA Certs)過期或找不到的狀況, 而現在真正要解決的狀況是讓沒有SSL憑證的網址不要出現錯誤...所以不要做驗證不就好了嗎:P

OpenSSL::SSL::VERIFY_NONE就是關鍵
網路上找到一些方案, 有滿多是全域性的設定, 但並非所有https都不做驗證, 所以此法不妥~~~
那要怎麼樣才能針對目前要連的網址不做驗證呢?
在open uri時, 設定驗證模式就搞定了...
require 'open-uri'

open(uri, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
問題找對方向, 沒想到這麼簡單就解決了XD


也可以用Net::HTTP來取代open uri的用法
require 'net/https'

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri.scheme == "https"  # enable SSL/TLS
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # important!!!
http.start {
  http.request_get(uri.path) { |res| 
    print res.body
  }
}

若有遇到相似問題的人, 以上方法可以參考看看囉:)

2014年9月5日 星期五

Rails Girl教練初體驗Day 1

之前參加LTRT的活動, 從各個教練學到許多:)
這次主辦單位舉辦Rails Girl 4, 有幸成為教練的一員
很開心有機會能分享所學, 貢獻小小的一己之力
雖然沒有教的很好, 但也謝謝學員們相當認真的在完成目標XD

分享一下我的教學歷程:

當然是follow Rails Girl 台灣官網 的教學是最順的啦:P

1. 第一步先來安裝環境啦~
因為我們都是Windows的使用者, 所以就是下載RailsInstaller來安裝啦
依照官網教程Rails 安裝食譜 - Windows 安裝教學, 很快就能完成安裝~~
在安裝時, 也順便把git給裝起來吧(選項要打勾)
現場網路有時會塞車, 安裝過程多半在等待下載, 因此就有空檔跟學員們說明什麼是Ruby, 什麼是Rails了...

2. 了解Ruby & Rails
還好有之前做的簡報可以用:P


只是簡介而已, 所以很快就講完了...
那...接下來...就...
Try Ruby吧XD
這網站真是自學教學兩相宜丫~

3. Try Ruby
透過Try Ruby網站, 可以學習Ruby的基本語法
把它當成遊戲來學習也不錯哦~~

和學員們邊練習邊說明, 學到Hash其實第一天的時間也差不多要接近尾聲了...
所以和學員們小聊了一下, 不管是想要多了解軟體開發流程或者覺得和電腦對話很有趣, 都可以感受到學員們認真的學習心態, 真的很棒:)

晚了, 也累了...期待第二天再繼續囉:P


2014年4月18日 星期五

我的Rails環境安裝(CentOS)

1. Linux環境準備
1.1. 在Windows上安裝VM & CentOS
VM使用VirtualBox or VMware皆可
CentOS挑釋出的最新版本download後, 在VM上安裝即可
基本上安裝都有操作界面可以按下一步, 所以沒有什麼難度, 其中有兩項我的選擇如下
  • Disc Found: 我選Skip the media test, 因為沒有什麼要測試的XD
  • 選擇要安裝的軟件: 我選Basic Server, 因為我沒打算要用桌面(有GUI), 也不想從Minimal什麼都沒有的情況下開始安裝開發工具:P
完整安裝步驟可參考:
http://wiki.debian.org.hk/w/Install_CentOS

1.2. 設定網路環境
查看目前的網路環境
# ifconfig
若只有看到local 127.0.0.1的資訊, 設定透過dhcp自動取得IP
# vim /etc/sysconfig/network-scripts/ifcfg-eth0
按i進入編輯模式, 輸入下列內容
ONBOOT="yes"
BOOTPROTO="dhcp"

按Esc鍵離開編輯模式後, 輸入:wq, 存檔並且離開文書編輯程式
(若要不存檔離開, 可輸入:q!)
啟動網路
# ifup eth0
方便內部環境測試, 直接關閉防火牆
# service iptables stop

1.3. 若安裝的CentOS不是最新版, 也可以安裝後直接更新
# yum clean all
# yum -y update
若發生Error: Package: matahari-XXX的錯誤, 因matahari在新版本已過時, 所以要刪掉
# yum remove matahari*
再執行一次update的指令來完成更新

1.4. 建立可以使用sudo執行屬於root權限指令的使用者, 使用者名稱以railsgirl為例
# useradd railsgirl
# passwd railsgirl
# visudo
找到root ALL=(ALL) ALL, 在該行下輸入下列內容
railsgirl ALL=(ALL) ALL

按Esc鍵離開編輯模式後, 輸入:wq, 存檔並且離開文書編輯程式

1.5. 切換使用者為railsgirl
# su railsgirl
上列的指令操作皆為root身份, 之後的操作皆以railsgirl的身份來進行
(因root為最高權限, 避免不小心去任意刪除到系統任何檔案, 對系統造成永久性損害, 我們以可以使用sudo的使用者來進行操作)


2. 開始安裝Rails
2.1. 安裝開發環境所需的工具
# sudo yum install make automake gcc gcc-c++ kernel-devel patch libffi-devel libtool bison openssl readline readline-devel curl git-core zlib zlib-devel openssl-devel libyaml-devel sqlite sqlite-devel libxml2 libxml2-devel libxslt-devel autoconf glibc-devel nodejs -y

2.2. 安裝圖像處理的工具
# sudo yum install ImageMagick -y

2.3. 安裝RVM(Ruby Version Manager)以及Ruby
指令參考來源:
https://rvm.io/rvm/install
http://ruby-china.org/wiki/rvm-guide
# curl -L get.rvm.io | bash -s stable --ruby
若發生下列錯誤
curl: (6) Couldn't resolve host 'rubygems.org'
There was an error while trying to resolve rubygems version for 'latest'. 
Halting the installation.
Gemset '' does not exist,       'rvm ruby-2.1.0 do rvm gemset create ' first, or append '--create'.
改手動安裝Ruby 2.0.0
# rvm install 2.0.0-p247

2.4. 使用一個Ruby版本並設為預設
# rvm use 2.0.0-p247 --default

2.5. 安裝Bundler(是管理應用程式Gem dependencies的管理工具, 會根據Gemfile的設定自動下載及安裝Gem套件, 並且能解決不同套件之間的依存關係)
Gem指令參考:
http://guides.rubygems.org/command-reference/
# gem install bundler --no-rdoc --no-ri

2.6. 安裝Rails
# gem install rails --no-rdoc --no-ri

2.7. 測試Rails
# rails new demo
# cd demo
# rails server
若發生下列錯誤
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
表示nodejs沒裝好, 再裝一次即可
# sudo yum install nodejs -y
若都沒有問題, 便可在Windows開啟browser去連剛啟動的rails網站囉!

最後, 來重開機(VM的Linux重啟), 再做一次測試, 若發現找不到指令的情形, 表示要再執行一次rvm use哪個ruby版本的指令
我們也可以直接在~/.bash_profile檔案裡最後一行加上該指令(rvm use 2.0.0-p247 --default), 就不用每次都要再執行一次啦~

2014年1月13日 星期一

初探Ruby on Rails

有緣人: 妳有聽過Rails嗎...
空空的我: 蛤~什麼??? 什麼Rails???

因緣際會, 有緣人讓我初步認識了Rails, 全名是Ruby on Rails(RoR), 是一套使用Ruby程式語言的Web開發框架. 據說能簡單且快速開發網站應用程式, 對沒有程式語言基礎的人來說似乎學習上也能很快樂:)

雖然我不認識她(Rails), 但我對她感興趣了...因此請google大神提供給我一些資訊.
什麼是Ruby on Rails, 以下連結已說明的非常清楚啦~
http://ihower.tw/rails3/intro.html
http://zh.wikipedia.org/wiki/Ruby_on_Rails

Ruby先鋒ihower寫的bible(http://ihower.tw/rails3/)是一本非常詳細的中文教學書籍, 因我還未準備好開發環境(打算在Windows上安裝VM再安裝Linux), 所以目前只拜讀到簡介就停擺了:P
沒想到過沒多久就從有緣人收到了一個很棒的資訊, 我的身份是可以參加Railsgirls讀書會的.

在台灣推廣Ruby以及Rails的先鋒們都有持續在舉辦一些技術交流的分享會, Rails Girls的活動是其中一項. 簡單來說, 該活動是希望能讓更多人感受Rails的魅力, 而且目標是要讓對程式這門領域較不熟悉的女性能透過Rails來實現技術面的想法; 更直白的來說, 就是不會寫程式的女性來參加活動, 也能輕易的學會架站及撰寫網頁啦~
不過很可惜活動已結束了, 但好佳在後續還有讀書會的活動可以和教練們交流, 所以我就去參加啦~

先來分享一下參加完讀書會的心得~
只能說主辦單位以及教練們真是佛心來著, 除了要繳場地費, 去學習是不用繳學費的. 而且每位學員都能配到一位教練, 一對一的教學; 偷偷觀察下來, 教練都超有心的, 依照學員的程度很有耐心的在指導, 內容甚至廣泛到一些電腦操作的技巧也有在教呢~
去要繳費的補習班上課都還享受不到這等待遇呢, 這時真心覺得身為女性...真是太好了:P
目前的讀書會報名網址: http://ltrt.kktix.cc/

在讀書會中, 我也確實學習到了Rails的開發以及利用Rails的框架工具來快速產生網站程式, 分享幾個學習的連結:
http://tryruby.org -> 15分鐘學Ruby程式語言, 透過互動模式, 學習挺有趣的~
http://railsgirls.tw/ -> Rails Girls指南, 提供相關入門教學, 必看~
http://railsgirls.tw/app/ -> 打造第一個App教學; 我的第一個App就是從這來的~
https://www.nitrous.io/#aio -> 雲端開發環境; 還未安裝好環境 , 就先用這個來學習吧~

我在雲端開發環境的第一個App~Step by Step分享~
1. 開啟Nitrouse.IO rails IDE環境, 如下圖
左視窗為目錄結構, 右為文字編輯器, 下則為命令列視窗

2. 輸入cd workspace指令, 切換到workspace目錄(該開發環境預設的工作路徑); 輸入rails new railsgirls來產生一個App
rails new可視為產生一個rails app的指令, 後面接的是要將app產生到哪個目錄下

3. 輸入cd railsgirls, 切換到railsgirls目錄; 輸入ruby bin/rails server來啟動伺服器(也可只輸入rails server來啟動)
成功啟動的訊息如下

4. 開啟測試伺服器的網頁
開啟的網頁畫面如下

5. 在命令列視窗Ctrl+C結束剛啟動Server的狀態, 回到可以輸入的狀態, 命令列有$的符號就是可以輸入的狀態了. 在接下來下一個步驟, 神奇的事即將要發生囉~

6. 輸入rails generate scaffold idea name:string description:text picture:string透過鷹架的功能來產生增(新增)/刪(移除)/改(編輯)/查(列出和檢視)皆具備的網頁; 輸入rake db:migrate讓資料庫更新, 能正確的和剛產生的網頁功能做串連.
rails generate scaffold可視為產生增/刪/改/查網頁功能的指令, 後面第一個參數接的就是該網頁的名稱, 再接下來則是功能對應的欄位及欄位屬性. 指令執行成功後, 會看到如下圖訊息, 列出自動產生出來的檔案.
資料庫更新完後, 會出現如下圖訊息

7. 最後, 依照之前的步驟來啟動伺服器及開啟測試頁面; 網頁開啟後, 在網址列最後加上/ideas, 會看到如下畫面
嘗試一下增/刪/改/查的功能吧
我的第一個App就這樣完成啦~
後續要美化頁面或者加強功能, 只要照著Rails Girls指南, 一步一步的去實作, 就能讓App更完整囉!

上述簡單的幾個步驟, 就能完成以往要寫好幾行程式以及頁面的功能, 真是太有效率啦~
所以我們回頭看一下, 她到底自動幫我們產生了哪些檔案:
controllers/ideas_controller.rb -> 處理ideas頁面的request, 與model互動後將資料輸出給view
models/idea.rb -> 包裝了資料管理與商業邏輯. 自動產生的model預設繼承了ActiveRecord, 所以基本的資料庫操作不需額外撰寫就都有囉
views/ideas/ -> ideas各個使用者介面, 顯示及編輯表單, 可內嵌Ruby程式的HTML
views/ideas/_form.html.erb -> 表單畫面, 以上述ideas為例, 為新增頁面及修改頁面裡的表單
views/ideas/index.html.erb -> 該功能首頁, 以上述ideas為例, 為Listing ideas列出頁面
...
在這些檔案修修改改, 也能很快的變成自己想要的樣子了吧~


因為剛認識Rails, 也還只是在初探的階段, 有很多不了解, 因此再拜了一下google大神, 查了一下我有興趣的內容; 其中一個議題是加上網頁框架後的老牌PHP和Rails的比較, 另一個議題則是效能上的問題了. 目前我還再參詳中, 先將連結筆記起來:)
Rails衝擊PHP(早期的文章)
http://www.ithome.com.tw/itadm/article.php?c=41491&s=3
Rails少就是多簡介(早期的文章)
http://guides.ruby.tw/creatingmoreusinglesseffortwithrubyonrails/
Ruby與PHP程式語言的比較(含Python)
http://www.nowamagic.net/librarys/veda/detail/2504
PHP 2013年前4名的框架
http://www.oschina.net/news/36494/the-best-php-framework-for-2013
效能問題探討(經驗分享)
Ruby去Rails化(指出Ruby本身效能是好的)
http://robbinfan.com/blog/40/ruby-off-rails

有一些問題, 就等著下次讀書會, 要來請教教練們啦~

最後要特別感謝有緣人(慕凡, 主辦者之一)以及讀書會教練(Vincent), 讓我有這個機會好好的認識Rails囉~