在删除时也传递:域。这个方法的来源是:
# Removes the cookie on the client machine by setting the value to an empty string
# and setting its expiration date into the past. Like []=, you can pass in an options
# hash to delete cookies with extra data such as a +path+.
def delete(name, options = {})
options.stringify_keys!
set_cookie(options.merge("name" => name.to_s, "value" => "", "expires" => Time.at(0)))
end
正如你所看到的,它只是设置了一个空cookie,名称与你给出的,设置为1969年到期,没有内容。但它会合并到您提供的任何其他选项中,因此您可以执行以下操作:
cookies.delete :foo, :domain => '.acme.com'
你已经准备好了。