[Rails] 分辨 symbol 和 string

遇到 Ruby 語法上,冒號 + 變數

routes.rb
1
2
3
4
5
resources :products do
member do
post :add_to_cart
end
end

products 就叫做 symbol

什麼是 Symbol?

翻譯上,符號象徵
可以直接說是,不可改變的字串

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×