ruby-on-rails - Rails 3.2.8,只有重启服务器才会取消缓存模型

标签 ruby-on-rails ruby-on-rails-3 caching model

我有一个在 Rails 3.2.8 上运行的 Rails 应用程序。

模型只会在我重新启动服务器时更新,对它们所做的任何更改都不会显示,直到服务器重新启动。

我正在开发中运行并且缓存类已关闭。

是否还有其他人遇到此问题,非常感谢您的帮助。谢谢。

我已经重新安装了 rvm、ruby 和我的 gemset。

我已经尝试了所有我能想到的方法来修复它。感谢大家的观看。

编辑:我在下面添加了大量的配置细节...

开发.rb

XXXXX::Application.configure do
  config.cache_classes = false
  config.whiny_nils = true
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.delivery_method = :sendmail
  config.active_support.deprecation = :log
  config.action_dispatch.best_standards_support = :builtin
  config.active_record.mass_assignment_sanitizer = :strict
  config.active_record.auto_explain_threshold_in_seconds = 0.5
  config.assets.compress = false
  config.assets.debug = true
  config.action_mailer.default_url_options = { :host => 'yyyy.xxxx.net' }

  #this is an attempt to fix the issues, didn't work
  config.to_prepare do
    ['algorithm', 'key_dates', 'roles', 'status'].each do | file_name |
      require "#{Rails.root}/app/models/user/#{file_name}.rb"
    end
  end

end

我的用户模型包含一些模块,如下所示:

class User < ActiveRecord::Base
  include Status, Roles, KeyDates, Algorithm
  #.....
end

模块是这样定义的

module User::Status

  def self.included(base)
    base.class_eval do
      extend ClassMethods
      include InstanceMethods
    end
  end
  #.....
end

应用.rb

require File.expand_path('../boot', __FILE__)

require 'csv'
require 'rails/all'

if defined?(Bundler)
  Bundler.require(*Rails.groups(:assets => %w(development test)))
end
module XXXXX
  class Application < Rails::Application
    config.encoding = "utf-8"
    config.filter_parameters += [:password]
    config.active_record.whitelist_attributes = true
    config.assets.enabled = true
    config.assets.version = '1.0'
    config.autoload_paths += Dir["#{config.root}/app/models/**/"]
    config.to_prepare do
      Devise::Mailer.layout "mailout"
      Devise::Mailer.helper :application
    end
  end
end

gem 锁:

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (3.2.8)
      actionpack (= 3.2.8)
      mail (~> 2.4.4)
    actionpack (3.2.8)
      activemodel (= 3.2.8)
      activesupport (= 3.2.8)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.0)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.1.3)
    activemodel (3.2.8)
      activesupport (= 3.2.8)
      builder (~> 3.0.0)
    activerecord (3.2.8)
      activemodel (= 3.2.8)
      activesupport (= 3.2.8)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.8)
      activemodel (= 3.2.8)
      activesupport (= 3.2.8)
    activesupport (3.2.8)
      i18n (~> 0.6)
      multi_json (~> 1.0)
    addressable (2.2.8)
    arel (3.0.2)
    aws-sdk (1.5.2)
      httparty (~> 0.7)
      json (~> 1.4)
      nokogiri (>= 1.4.4)
      uuidtools (~> 2.1)
    bcrypt-ruby (3.0.1)
    builder (3.0.0)
    cocaine (0.2.1)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.3.3)
    devise (2.1.0)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.0.7)
      railties (~> 3.1)
      warden (~> 1.1.1)
    devise_invitable (1.0.2)
      devise (>= 2.0.0)
      rails (~> 3.0)
    erubis (2.7.0)
    execjs (1.3.2)
      multi_json (~> 1.0)
    faker (1.0.1)
      i18n (~> 0.4)
    heroku (2.25.0)
      launchy (>= 0.3.2)
      netrc (~> 0.7.1)
      rest-client (~> 1.6.1)
      rubyzip
    hike (1.2.1)
    httparty (0.8.3)
      multi_json (~> 1.0)
      multi_xml
    i18n (0.6.0)
    journey (1.0.4)
    jquery-rails (2.0.2)
      railties (>= 3.2.0, < 5.0)
      thor (~> 0.14)
    json (1.7.5)
    launchy (2.1.0)
      addressable (~> 2.2.6)
    mail (2.4.4)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.19)
    multi_json (1.3.6)
    multi_xml (0.5.1)
    mysql2 (0.3.11)
    netrc (0.7.1)
    nokogiri (1.5.2)
    orm_adapter (0.0.7)
    paperclip (2.7.0)
      activerecord (>= 2.3.0)
      activesupport (>= 2.3.2)
      cocaine (>= 0.0.2)
      mime-types
    pg (0.13.2)
    polyglot (0.3.3)
    rack (1.4.1)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.2)
      rack
    rack-test (0.6.1)
      rack (>= 1.0)
    rails (3.2.8)
      actionmailer (= 3.2.8)
      actionpack (= 3.2.8)
      activerecord (= 3.2.8)
      activeresource (= 3.2.8)
      activesupport (= 3.2.8)
      bundler (~> 1.0)
      railties (= 3.2.8)
    railties (3.2.8)
      actionpack (= 3.2.8)
      activesupport (= 3.2.8)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    rake (0.9.2.2)
    rdoc (3.12)
      json (~> 1.4)
    redcarpet (1.17.2)
    rest-client (1.6.7)
      mime-types (>= 1.16)
    rubyzip (0.9.8)
    sass (3.1.18)
    sass-rails (3.2.5)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    sequel (3.20.0)
    sinatra (1.0)
      rack (>= 1.0)
    sprockets (2.1.3)
      hike (~> 1.2)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sqlite3 (1.3.6)
    taps (0.3.24)
      rack (>= 1.0.1)
      rest-client (>= 1.4.0, < 1.7.0)
      sequel (~> 3.20.0)
      sinatra (~> 1.0.0)
    thor (0.16.0)
    tilt (1.3.3)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.33)
    uglifier (1.2.4)
      execjs (>= 0.3.0)
      multi_json (>= 1.0.2)
    uuidtools (2.1.2)
    warden (1.1.1)
      rack (>= 1.0)

PLATFORMS
  ruby

DEPENDENCIES
  aws-sdk
  coffee-rails (~> 3.2.1)
  devise
  devise_invitable
  faker
  heroku
  jquery-rails
  mysql2
  paperclip (~> 2.7)
  pg
  rails (= 3.2.8)
  redcarpet (= 1.17.2)
  sass-rails (~> 3.2.3)
  sqlite3
  taps
  uglifier (>= 1.0.3)

最佳答案

如果没有看到你的项目文件(尤其是 Gemfile、config/environments/development.rb、application.rb),很难提出尖锐的建议,但你总是可以生成全新的 Rails 项目,并在几分钟内逐一传输您当前的项目文件到最近创建的文件以确定导致问题的确切 gem 或文件。我希望在那之后修复它会容易得多。这是一种蛮力,但可以帮助击倒情况

关于ruby-on-rails - Rails 3.2.8,只有重启服务器才会取消缓存模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12570137/

相关文章:

jquery - Zurb Foundation 5 下拉菜单(导航栏和数据内容)偶尔(随机)不响应点击

php - 应用程序服务器从哪里开始

ruby-on-rails - Rails for Zombies - 实验室

javascript - 两个不同 Rails Assets 的单个 javascript 文件依赖性

ruby-on-rails - heroku db :push not working, 使用 taps gem

ruby-on-rails - Rails - 在 image_tag 中插入变量

java - 使用 websphere api 获取当前应用程序实例?

带有外部更新的 NHibernate 二级缓存

node.js - 对于 Node/Mongo/NginX,哪种缓存方法最快/最轻?

mysql - 事件记录,其中 {}