jjzjj

update-cache

全部标签

ruby-on-rails - 部署时 "Warm Up Cache"

我想知道是否有人有任何插件或capistrano配方可以通过在部署时或在本地部署之前构建所有页面缓存的html来“预热”rails应用程序的页面缓存。我有一些主要是静态的网站,它们变化不大,如果已经编写了html,运行速度会更快,而不是要求一位访问者访问该网站。与其自己创建它(看起来很简单,但它的优先级很低),它是否已经存在? 最佳答案 您可以使用wget或其他程序来抓取站点。事实上,这种场景在其手册页中被提及为一种用途:ThisoptiontellsWgettodeleteeverysinglefileitdownloads,af

ruby-on-rails - has_many :through with counter_cache

据我了解,在定义:counter_cache选项时,应在包含belongs_to声明的模型上指定它。所以我有点不确定在通过关联使用has_may时如何处理这个问题(因为我相信在这种情况下不使用belongs_to声明):classPhysician:appointmentsendclassAppointmentappointment_countendclassPatient我希望使用:counter_cache选项来更有效地查找属于医生的患者数量。myPhysician.patients.count仅供引用:Rails3.1干杯 最佳答案

ruby-on-rails - 未定义方法 `cache' 为 nil :NilClass after upgrading to rails 4. 2.5.1

从Rails4.2.5升级到最近发布的4.2.5.1时,我遇到了这个错误。此错误仅适用于具有呈现无效状态的before_filter的规范,例如renderfile:"public/422",status::unauthorized。我在ruby​​-2.2.2和ruby​​-2.3.0上都收到了这个错误错误存在于action_view解析器方法中,暗示@cache值为nil。然而,在initialize方法中它应该被实例化:@cache=Cache.new我仍在研究可重现的样本,但到目前为止我还不知道@cache怎么可能是nil。这些是在我的test.rb环境中设置的配置变量conf

ruby-on-rails - 可以安全删除 rails tmp/cache/assets 文件吗?

我似乎在命名为example的子文件夹中有很多它们sprockets%2F76920e6913c3390459175ac8e6dfd44a3它们似乎包含二进制数据。它们的用途是什么,为什么有这么多,最重要的是,可以安全地移除它们吗?他们需要永远的scp。 最佳答案 是的!您可以删除整个tmp目录,它将被重新创建。 关于ruby-on-rails-可以安全删除railstmp/cache/assets文件吗?,我们在StackOverflow上找到一个类似的问题:

ruby-on-rails - counter_cache 与 has_many :through

我刚刚创建了一个counter_cache字段,Controller看起来像这样。@users=User.where(:sex=>2).order('received_likes_count')User.rb中的关联是has_many:received_likes,:through=>:attachments,:source=>:likes,:dependent=>:destroy问题是counter_cache是在Like.rb的belong_to中声明的,我不知道如何告诉它它是用于has_many:through关联。belongs_to:user,:counter_cache=>

关于Document mapping type name can‘t start with ‘_‘, found: [_update]

在修改elasticsearch时,用_update进行局部修改,修改失败,报错{    "error": {        "root_cause": [            {                "type": "invalid_type_name_exception",                "reason": "Document mapping type name can't start with '_', found: [_update]"            }        ],        "type": "invalid_type_name_exce

自动化update_post_meta

因此,我一直在研究此旧代码,并且正在尝试改进它。我有这个代码,从帖子中节省了许多自定义字段。if(isset($_REQUEST['unidade-dir1-cargo'])){update_post_meta($post_id,'unidade-dir1-cargo',sanitize_text_field($_POST['unidade-dir1-cargo']));update_post_meta($post_id,'unidade-dir1-nome',sanitize_text_field($_POST['unidade-dir1-nome']));update_post_meta(

ruby-on-rails - rails 中的 create_or_update 方法

ifClassName.exists?(["id=?",self.id])object=ClassName.find_by_name(self.name)object.update_attributes!(:street_address=>self.street_address,:city_name=>self.city_name,:name=>self.org_unit_name,:state_prov_id=>self.state_prov_id,:zip_code=>self.zip_code)elseClassName.create!:street_address=>self.

ruby-on-rails - 将 bool 值传递给 update_attributes 的问题

我有以下模型:classGuestCateringtruevalidates:order_number,:presence=>truevalidates:orderable,:presence=>trueend但是当我尝试使用以下代码更新现有的GuestCatering时:guest_catering.update_attributes(:orderable=>false)guestcatering变量是一个有效的GuestCatering对象。guest_catering对象更新后出现错误,像这样:nil}>但是当我传递一个orderable=>true时,一切都很好,没有错误。这里

ruby - bundler 能告诉我 Gemfile 中的哪些 gems 有更新的版本吗(例如 bundle update 的试运行)

有没有办法运行bundleupdate在假装模式下,类似于Rails生成器的-p(假装)标志或cap的-n(试运行)标志?我在想像这样的事情:$>bundleupdate-pFetchingsourceindexforhttp://rubygems.org/Thefollowinggemshaveupdatedversions:...listofgems... 最佳答案 Bundler1.1引入了一个新的“过时”功能,这正是我一直在寻找的。PatShaughnessy很棒write-up关于新功能。用他的话说,bundleoutda