如何防止轨道缓存 Model.all 查询



我不明白为什么在开发模式下,即使在插入新记录后,查询也会被缓存。我的意思是,在创建新记录后,我的 Model.all 不会从数据库中提取该记录。我与IRB核对,记录仍然存在。重新启动服务器后,将显示新记录。

这是细节...

  • 所有环境配置都是由"Rails New App"生成的标准配置。

第一次启动服务器后,当我点击页面控制器#索引时,日志是

Processing by PagesController#index as HTML
  Page Load (14.9ms)  SELECT "pages".* FROM "pages" 
  Rendered pages/index.html.erb within layouts/application (4.1ms)
Completed 200 OK in 237ms (Views: 167.5ms | ActiveRecord: 16.9ms)

创建页面后,用户被重定向到索引操作,日志是

Started GET "/pages" for 127.0.0.1 at 2012-06-13 09:40:27 -0400
 Processing by PagesController#index as HTML
 Rendered pages/index.html.erb within layouts/application (1.6ms)
Completed 200 OK in 5ms (Views: 5.2ms | ActiveRecord: 0.0ms)

我的操作

def index
  @pages = Page.all
end
def create
  @page = Page.new(params[:page])
  if @page.save
    flash[:notice] = "Page saved Successfully"
    redirect_to :action => "index"
  else
    flash[:alert] = "Errors on saving the page"
    render :action => "new"
  end
end
我对

rails很陌生,在我对这个问题的研究中找不到任何东西。有人可以帮我吗?

宝石

  • 操作邮件程序 (3.2.4)
  • 操作包 (3.2.4)
  • 活动模型 (3.2.4)
  • 活动记录 (3.2.4)
  • 活动资源 (3.2.4)
  • 主动支持 (3.2.4)
  • 阿雷尔 (3.0.2)
  • bcrypt-ruby (3.0.0)
  • 生成器 (3.0.0)
  • 捆绑器 (1.1.4)
  • ci_reporter (1.7.0)
  • 咖啡导轨 (3.2.1)
  • 咖啡脚本 (2.2.0)
  • 咖啡脚本源 (1.3.3)
  • 埃鲁比斯 (2.7.0)
  • 执行 (1.4.0)
  • 远足 (1.2.1)
  • i18N (0.6.0)
  • 旅程 (1.0.3)
  • JSON (1.7.3)
  • libv8 (3.3.10.4 x86_64-达尔文-11)
  • 邮件 (2.4.4)
  • 元类 (0.0.1)
  • 哑剧类型 (1.18)
  • 摩卡 (0.11.4)
  • multi_json (1.3.6)
  • 红绿 (0.7.1)
  • 多语言 (0.3.3)
  • 机架 (1.4.1)
  • 机架缓存 (1.2)
  • 机架式 SSL (1.3.2)
  • 机架测试 (0.6.1)
  • 导轨 (3.2.4)
  • 导轨 (3.2.4)
  • 耙子 (0.9.2.2)
  • RDOC (3.12)
  • 红宝石捆绑器 (1.0.2)
  • RVM (1.11.3.3)
  • 萨斯 (3.1.19)
  • 导轨 (3.2.3)
  • 链轮 (2.1.3)
  • SQLite3 (1.3.6)
  • 术语-安西色 (1.0.7)
  • 红宝石赛车 (0.10.1)
  • 雷神 (0.15.2)
  • 倾斜 (1.3.3)
  • Tinymce-rails (3.5)
  • 树顶 (1.4.10)
  • TZINFO (0.3.33)
  • 丑陋 (1.0.3)

Rails 3.2.4 在缓存 findall 时遇到了问题。我建议你升级到更新版本的Rails,根据这个问题:Rails 3.2.4 SQL查询正在查找(:all)上缓存结果

最新更新