Ruby for Rails 學習心得01

Ruby for Rails : Rails開發者必備的Ruby學習手冊 –> 大推

Ruby code 怎麼去寫讀local檔和建立新文字檔,修改文字檔:
1. read file
a = File.read(“filename")

2. create file
a = File.new(“filename", “w")
a.close

3. write to file
a = File.new(“filename", “w")
a.puts b
a.close

*** ruby tool 實用工具(大推):
1. ruby -r debug filename (debug)
2. ruby -r profile filename (check utilization)

*** what’s erb 什麼是 .erb
1. 在html檔案裡面,置入Ruby code
2. 將RoR模子->操作->呈現,就是最後一個呈現網頁結果,通常會是或是
3. 執行erb和執行rb不一樣,執行erb要用 “erb filename"

*** 所謂的MVC結構
串起M-V-C,一定是Rails:

/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rails-3.0.1

M的解釋:

Model (ActiveRecord): /usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-2.3.2/

C的解釋:

Control (ActionController): /usr/local/rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.1/lib/action_controller

V的解釋:

View (ActionView): /usr/local/rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.1/lib/action_view

發表留言