简体   繁体   English

在Rails控制台中访问私有方法

[英]Access private methods in the rails console

I'm experimenting with n+1 queries in the rails console, but running 我正在Rails控制台中尝试n + 1个查询,但是正在运行

> Zombie.include(:brain).all.each do |z| z.brain end

Results in this error: 导致此错误:

NoMethodError: private method `include' called for #<Class:0x000000045bf2a8>

Is there anway I can access the include method? 有没有办法我可以访问include方法? A sort of sudo method that gives the console access to all of my application's methods? 一种sudo方法,可让控制台访问我所有应用程序的方法?

I'm fairly sure you want includes there :) 我相当确定您想要在includes :)

  • includes comes from ActiveRecord::Base includes来自ActiveRecord :: Base
  • include comes from Module include来自模块

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM