路由helper

root_url          http://192.168.1.110:3000/users/sign_up?inviter=14658733081530
root_path       /users/sign_up?inviter=14658733081530class => (action_name == "" ? "a" : nil)
request.path => ***_path

Request 資訊收集
在 Controller 的 Action 之中,Rails 提供了一些方法可以讓你得知此
request 各種資訊,包括:
 action_name 目前的 Action 名稱
 cookies Cookie 下述
 headers HTTP 標頭
 params 包含用戶所有傳進來的參數 Hash,這是最常使用的資
訊

request 各種關於此 request 的詳細資訊
 request_method
method
delete?, get?, head?, post?, put?
 xml_http_request? 或 xhr?
 url
 protocol, host, port, path 和 query_string

domain
host_with_port
port_string
ssl?
remote_ip?
path_without_extension,
path_without_format_and_extension, format_and_extension,
relative_path
env
accepts
format
mime_type
content_type
headers
body
content_length
response 代表要回傳的內容,會由 Rails 設定好。通常你會用
到的時機是你想加特別的 Response Header。

session Session 下述
正確的說, params 這個 Hash 是 ActiveSupport::HashWithIndifferentAccess
物件,而不是普通的 Hash 而已。Ruby 內建的 Hash,用 Symbol 的 hash[:foo]和用字
串的 hash["foo"]是不一樣的,這在混用的時候常常搞錯而取不到值,算是常見的臭
蟲來源。Rails 在這裡使用的 ActiveSupport::HashWithIndifferentAccess 物
件,無論鍵是 Symbol 或字串,都指涉相同的值,減少麻煩。

 

转载于:https://www.cnblogs.com/znsongshu/p/6080231.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值