Tag: 负载

是否每次加载页面时都会执行每个相关计算?

我有一个模型“Wrapper”,其中包含另一个模型“Category”,其中又有另一个模型“Thing”。 “Thing”具有整数属性:count和:number 。 它还有一个在models/thing.rb定义的实例方法: def ratio (self.count + self.number).to_f / Thing.all.count.to_f end 那么,“类别”具有此实例方法,在models/category.rb定义: def thing_ratios self.things.sum(&:ratio.to_f) end 最后,我的wrapper.html.erb视图显示了按照thing_ratios顺序列出的thing_ratios : … 我的问题是这样的:每次有人重新加载页面wrapper.html.erb ,是否必须重新计算每一个相关计算,一直到每个与页面上每个类别相关的Thing的self.count ?

Ruby on Rails:无法加载

什么是可unloadable ? 我在thinkbot的高压页面控制器中看到了这个。 thinkbot关于可卸载的博客 ,但我仍不清楚它的作用。

Ruby Rake从gem中加载任务

我一直在尝试将位于github上的gem添加到我当前的应用程序中。 gem有一个rake文件,我希望能够从我的应用程序访问。 但我不断加载错误。 load ‘tasks/deploy.rake’ gem文件看起来像那样 # -*- encoding: utf-8 -*- require ‘rake’ Gem::Specification.new do |gem| gem.authors = %w(Hello World) gem.email = %w(test@example.com) gem.description = ‘test’ gem.summary = ‘test’ gem.homepage = ‘https://github.com/..’ gem.files = FileList[ ‘lib/**/*.rb’, ‘tasks/deploy.rake’, ‘README.md’ ].to_a gem.name = ‘test’ gem.require_paths = %w(lib) gem.version = ‘0.0.1’ end 我希望能够将./tasks/deploy.rake加载到包含此gem的应用程序中,我该如何继续呢? 谢谢