設計 method 時,你可以決定給他帶一個參數,還是數個參數,i.e:
def writing(name, email, id, work_address, phone_number) …
在現在的網站,我們通常會給網址帶像是 utm 參數,來做資料分析,i,e:…
中文文章
HashWithIndifferentAccess
rack是一個協定(protocol),是一個接口(interface),來傳遞 HTTP request/response。透過rack能夠連結到我們的Ruby web app。
現在我們先來寫個簡單的rack app,如果你的還沒裝rack,可以下指令gem install rack來安裝。
gem install rack
# first_rack_app.rbrequire "rack"class FirstRackApp def…
初學者會學到,Ruby 的 string可以用 + 串接的寫法,i.e:
+
"a" + "b" + "c"
我們先從 rails 的 parameter 開始談 我們常會用 params[:id] 來撈資料,但是為何 params 會有像是Ruby hash 的操作呢?
params[:id]