- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
是否有一种方法可以否定作用域的结果?我有 3 个模型,由 has_many 关联:通过关联
用户.rb
class User < ActiveRecord::Base
has_many :user_training_maps
has_many :trainings, through: :user_training_maps
end
训练.rb
class Training < ActiveRecord::Base
has_many :user_training_maps
has_many :users, through: :user_training_maps
end
user_training_map.rb
class UserTrainingMap < ActiveRecord::Base
belongs_to :user
belongs_to :training
end
之前,我想找到属于(注册)培训的所有用户。在 user.rb 中,这有效:
scope :all_enrolled, -> { joins(:trainings) }
现在,我需要帮助找到所有不属于(未注册)培训的用户。我无法让它工作:scope :all_unenrolled, -> { !joins(:trainings) }
相反,它只是返回所有用户。类似未注册用户 =(所有用户)-(已注册用户)
最佳答案
试试这个
scope : all_enrolled, -> { joins(:trainings) }
范围:not_enrolled,-> { where.not(id: all_enrolled) }
关于ruby-on-rails - 范围的倒数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48273854/
如果我有一个变量 8589934592 示例: var a = (8589934592 | 0); //a is 0 var b = (8589934591223 | 0); //b
随着我们提高音阶,音符频率增加; #define A4 440 // These are the frequencies of the notes in herts #define A
我有一个这样组织的列表: [('down', 0.0098000000000000309), ('up', 0.0015000000000000568), ('down', 0.00890000000
如果我有一个多项式 P,有没有办法计算 P^-1 模 Q,即 Q 是另一个多项式?我知道这两个多项式的系数都属于以 z 为模的整数域,即 z 是一个整数。 我不确定 SymPy 是否已经在其 galo
对于给定的文件,我可以向后计算行数吗?即从 EOF 开始,计算行数直到开始? 我可以 fseek 到文件末尾。从那里开始,继续寻找新行字符(新行的指示)并继续增加我的 line_number 计数。但
有什么方法可以编写带除法的 C 代码来命令编译器在代码中需要常规除法精度的几个特定位置不使用快速除法(通过倒数数学),即使在全局允许倒数数学的情况下也是如此? 理想情况下,有一种方法不是特定于编译器的
我正在尝试将照片从我计算机上的本地文件导入到我的 HTML 文件中。我已经设法做到了,但它是按升序排列的。我尝试添加一个变量 JavaScript $(document).ready( functio
我正在尝试使用 commons-math 计算 2 尾学生分布的逆。我正在使用 Excel 来比较值并验证结果是否正确。 所以使用excel计算TINV,自由度为5,我使用95.45% =TINV(0
我有一个 jQuery 相机插件,它使用以下命令来拍摄快照。 这是它运行的代码。 function take_snapshot() { // take snapshot and get i
我刚刚学会了训练 brain.js network 并且只是在玩它。然后我很好奇是否可以采取相反的方式 - 从输出预测输入? 这是我的代码 const brain = require('brain.j
如果精度不重要,有什么方法可以提高速度的倒数(X 的除法 1)? 所以,我需要计算 1/X。是否有一些解决方法让我失去精度但做得更快? 最佳答案 𝗛𝗲𝗿𝗲𝗛𝗲𝗿𝗲𝗛𝗼𝘄𝗧𝗼?
令 N 为整数。如果N = 2536,则反转N为6352。如果N = 1000000,则反转N为1。 给定一个整数 M,其中 1 <= M <= 10^(100000)。 我们需要找到一个整数 N 是
我是一名优秀的程序员,十分优秀!