English 中文(简体)
具有特殊参数的可磨和复健的铁路
原标题:Disable and refreshing rails cache with special parameter

我在铁路上使用沥滤,但有时我可以提出具体要求,或重新提出(生产中)焦土数据。 我因此想去做,只是看看两者的业绩差别。

  1. Is there a way to turn off caching (with something like &cache=false) across the board without adding things like this throughout my code:

    <% cache(x) unless params[:cache] == "false" do %>
    
  2. 难道有办法告诉铁路公司,使其所有线性元素失效,因为它使该页重新启用? 这将发挥作用,但我不得不在任何地方这样做:

    <% Rails.cache.delete <key> if params[:clear_cache] == "true" %>
    

或者有很好的理由,为什么我根本就不应该这样做。

最佳回答

你们总是可以写出,把它当作一种你而不是“切身”的方法。

def my_cache(x)
   return x if params[:cache].blank? || params[:cache] == true
   cache(x)
end

这在你看来是轻松的。

或者,请<>might (i m guessing) 能够使用ActionController:Base在内部进行缝.......但根据铁路法进行洗 met。

问题回答

暂无回答




相关问题
Remove ActiveRecord in Rails 3

Now that Rails 3 beta is out, I thought I d have a look at rewriting an app I have just started work on in Rails 3 beta, both to get a feel for it and get a bit of a head-start. The app uses MongoDB ...

When will you upgrade your app to Rails 3? [closed]

Now that the Rails 3 beta is here, let s take a little straw poll. Please tell us briefly what your application does and when you will upgrade it to Rails 3. Or, if you re not planning on upgrading ...

Bundler isn t loading gems

I have been having a problem with using Bundler and being able to access my gems without having to require them somewhere, as config.gem used to do that for me (as far as I know). In my Rails 3 app, I ...

bypass attr_accessible/protected in rails

I have a model that, when it instantiates an object, also creates another object with the same user id. class Foo > ActiveRecord::Base after_create: create_bar private def create_bar Bar....

concat two fields activerecord

I m so used to oracle where you can simply concat(field1, , field2) but if I m using activerecord to find the field1 and field2, and I need a space in between, how do I accomplish this? Cheers ...

热门标签