我刚刚在这里阅读(http://ruby.runpaint.org/programs#lexical)评论是令牌.我从来没有把评论视为令牌,因为它们既可以是注释,也可以是后处理器.
评论真的是令牌还是这个来源错了?
我的协会是这样的:
vendor has shipments
shipment has order
order has products
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我写了
@shipments = @vendor.shipments.includes(:order)
Run Code Online (Sandbox Code Playgroud)
但在我看来,我正在使用
shipment.order.products.collect(&:name)
Run Code Online (Sandbox Code Playgroud)
所以它正在返回Rails'bullet'gem的N + 1 Query问题
任何人帮我解决嵌套N + 1查询问题?我怎么需要在控制器中写?
我正在尝试通过他们的IP地址本地化我的用户.正如文档所说,一个被称为类的方法geocode_ip_address已被混合到了ActionController::Base.但是必须有一些我想念的东西.我是否必须定义这样的过滤器before_filter :geocode_ip_address才能使用它?(我想知道每个请求的位置).
该文档还讨论了"首次查找将导致GeoLoc类存储在会话中:geo_location",但我当然没有在会话哈希中使用该密钥.
我究竟做错了什么?
谢谢.
我想加入两个或更多这样的哈希.
h1 = { :es => { :hello => "You" } }
h2 = { :es => { :bye => "Man" } }
Run Code Online (Sandbox Code Playgroud)
我怎么能得到这个?
h1 + h2 = { :es => { :hello => "you", :bye => "Man" } }
Run Code Online (Sandbox Code Playgroud)
谢谢.
当我在我的凤凰应用程序中运行自定义混合任务(我认为它甚至不与凤凰相关但仍然)使用一些外部库(例如https://github.com/knrz/geocoder)我得到
** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
:erlang.send(:geocoder_workers, {:"$gen_cast", {:cancel_waiting, #Reference<0.0.1.13074>}}, [:noconnect])
Run Code Online (Sandbox Code Playgroud)
直到我添加
Application.ensure_all_started(:geocoder)
混合任务.所以我的问题是为什么我的所有依赖项都不会自动启动?是我做错了什么?