Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Redis和Rails在生产上出错:ActionView::Template::Error(错误无效的DB索引)_Ruby On Rails_Database_Caching_Redis - Fatal编程技术网

Ruby on rails Redis和Rails在生产上出错:ActionView::Template::Error(错误无效的DB索引)

Ruby on rails Redis和Rails在生产上出错:ActionView::Template::Error(错误无效的DB索引),ruby-on-rails,database,caching,redis,Ruby On Rails,Database,Caching,Redis,当我在开发时,我加载页面,它工作正常。没有错误。我在staging上加载页面,得到一个404。我试图做的是缓存页面的一部分以提高性能 这是我在书面记录中发现的错误: Processing by InstructorsController#index as HTML app/web.1: Read fragment views/staging.example.com/instructors?expires_in=86400/d373c7125bca0fa7485862a5e9f72b99 (1

当我在开发时,我加载页面,它工作正常。没有错误。我在staging上加载页面,得到一个404。我试图做的是缓存页面的一部分以提高性能

这是我在书面记录中发现的错误:

Processing by InstructorsController#index as HTML 
app/web.1:  Read fragment views/staging.example.com/instructors?expires_in=86400/d373c7125bca0fa7485862a5e9f72b99 (10.2ms) 
app/web.1:  Completed 500 Internal Server Error in 238ms 
app/web.1:  cache: [GET /instructors] miss 
app/web.1:  Started GET "/instructors" for 12.34.567.89 at 2014-05-18 23:46:47 +0000 
app/web.1:    Cache digest for app/views/instructors/index.html.erb: d373c7125bca0fa7485862a5e9f72b99 
app/web.1:    Rendered instructors/index.html.erb within layouts/application (14.2ms) 
app/web.1:  ActionView::Template::Error (ERR invalid DB index): 
app/web.1:      1: <% cache expires_in: 1.day do %> 
app/web.1:      2:   <% set_meta_tags keywords: @instructors.keywords %> 
app/web.1:      3:  
app/web.1:      4:   <section id="instructors" class="panel panel-default"> 
app/web.1:    app/views/instructors/index.html.erb:1:in `_app_views_instructors_index_html_erb__1873438065652455666_70314031777140' 
heroku/router:  at=info method=GET path=/instructors host=staging.example.com request_id=c30153a3-bf5d-4e87-ab4f-45e1148db83b fwd="12.34.567.89" dyno=web.1 connect=1ms service=260ms status=500 bytes=1789
现在,您知道出了什么问题,以下是所有redis信息:

# redis.conf
daemonize no
databases 128

# config/environments/production.rb
config.action_controller.perform_caching = true
config.cache_store                       = :redis_store, "#{ENV['REDISCLOUD_URL']}/1"
config.action_dispatch.rack_cache        = {
  metastore:   "#{ENV['REDISCLOUD_URL']}/1/metastore",
  entitystore: "#{ENV['REDISCLOUD_URL']}/1/entitystore"
}

# config.ru
require 'rack'
require 'rack/cache'
require 'redis-rack-cache'

use Rack::Cache,
    metastore:   "#{ENV['REDISCLOUD_URL']}/0/metastore",
    entitystore: "#{ENV['REDISCLOUD_URL']}/0/entitystore"

# Gemfile
source 'https://rubygems.org'
ruby '2.1.2'

gem 'rails', '4.1.1'
gem 'mysql2'
gem 'thin'
gem 'redis-store'
gem 'redis-rails'
gem 'redis-rack-cache'
gem 'redis-namespace'

# app/controllers/instructors_controller.rb
class InstructorsController < ApplicationController
  def index
    @instructors = Instructor.all
  end

  def show
    @instructor = Instructor.find(params[:id])
  end
end

# db/schema.rb
# there are no indexes to be found for the instructors.
create_table "instructors", force: true do |t|
  t.string   "first_name"
  t.string   "last_name"
  t.string   "handle"
  t.string   "google_plus"
  t.text     "bio"
  t.string   "avatar"
  t.datetime "created_at"
  t.datetime "updated_at"
end

# Procfile
web: bundle exec thin start -p $PORT
redis: redis-server redis.conf
#redis.conf
daemonize no
数据库128
#config/environments/production.rb
config.action\u controller.perform\u caching=true
config.cache_store=:redis_store,“#{ENV['REDISCLOUD_URL']}/1”
config.action\u dispatch.rack\u cache={
元存储:“{ENV['REDISCLOUD\u URL']}/1/metastore”,
entitystore:“{ENV['REDISCLOUD\u URL']}/1/entitystore”
}
#config.ru
需要“机架”
需要“机架/缓存”
需要“redis机架缓存”
使用Rack::Cache,
元存储:“{ENV['REDISCLOUD\u URL']}/0/metastore”,
entitystore:“{ENV['REDISCLOUD\u URL']}/0/entitystore”
#Gemfile
来源'https://rubygems.org'
ruby“2.1.2”
gem“rails”、“4.1.1”
gem'mysql2'
宝石“薄”
宝石“redis商店”
宝石“redis rails”
gem“redis机架缓存”
gem“redis命名空间”
#app/controllers/instructors\u controller.rb
类讲师控制器<应用程序控制器
def索引
@讲师=讲师
终止
def秀
@讲师=讲师。查找(参数[:id])
终止
终止
#db/schema.rb
#找不到讲师的索引。
创建“讲师”表,强制:true do | t|
t、 字符串“first_name”
t、 字符串“姓氏”
t、 字符串“句柄”
t、 字符串“google_plus”
t、 “生物”文本
t、 字符串“阿凡达”
t、 日期时间“创建时间”
t、 日期时间“更新时间”
终止
#程序文件
web:bundle exec精简启动-p$端口
redis:redis服务器redis.conf

请记住,为了让您快速浏览,我将其保持简短。我几乎总是在线,所以如果你需要更多信息,请留下评论。我不介意。

如果我没有弄错的话,您的生产环境似乎使用了共享的/1数据库,而Redis Cloud不支持该数据库,尽管在语法上没有错误。相反,您应该只使用/0数据库,因为Redis Cloud的所有数据库都是专用的-有关此主题的更多信息,请参阅

如果我没有弄错的话,您的生产环境似乎使用了共享/1数据库,而Redis Cloud不支持共享/1数据库,虽然在语法上没有错误。相反,您应该只使用/0数据库,因为Redis Cloud的所有数据库都是专用的-有关此主题的更多信息,请参阅《解决潜在问题的方法》。不过,我仍然得到相同的索引错误。我会寻找原因,但是我的
config.ru
(rack(读:rack up for ru)是rails中启动服务器的部分)现在读到了
/1
。如果你还看到什么,请告诉我。我还向讲师表添加了索引。糟糕的是,它们都在使用
/0
。。。仍在获取错误。找到它。我还在生产缓存中声明
/1
。在1184ms内
完成的200 OK现在是
在264ms内完成的200 OK
。翻页速度快了四倍半。你真棒!这就解决了潜在的问题。不过,我仍然得到相同的索引错误。我会寻找原因,但是我的
config.ru
(rack(读:rack up for ru)是rails中启动服务器的部分)现在读到了
/1
。如果你还看到什么,请告诉我。我还向讲师表添加了索引。糟糕的是,它们都在使用
/0
。。。仍在获取错误。找到它。我还在生产缓存中声明
/1
。在1184ms内
完成的200 OK现在是
在264ms内完成的200 OK
。翻页速度快了四倍半。你真棒!
# redis.conf
daemonize no
databases 128

# config/environments/production.rb
config.action_controller.perform_caching = true
config.cache_store                       = :redis_store, "#{ENV['REDISCLOUD_URL']}/1"
config.action_dispatch.rack_cache        = {
  metastore:   "#{ENV['REDISCLOUD_URL']}/1/metastore",
  entitystore: "#{ENV['REDISCLOUD_URL']}/1/entitystore"
}

# config.ru
require 'rack'
require 'rack/cache'
require 'redis-rack-cache'

use Rack::Cache,
    metastore:   "#{ENV['REDISCLOUD_URL']}/0/metastore",
    entitystore: "#{ENV['REDISCLOUD_URL']}/0/entitystore"

# Gemfile
source 'https://rubygems.org'
ruby '2.1.2'

gem 'rails', '4.1.1'
gem 'mysql2'
gem 'thin'
gem 'redis-store'
gem 'redis-rails'
gem 'redis-rack-cache'
gem 'redis-namespace'

# app/controllers/instructors_controller.rb
class InstructorsController < ApplicationController
  def index
    @instructors = Instructor.all
  end

  def show
    @instructor = Instructor.find(params[:id])
  end
end

# db/schema.rb
# there are no indexes to be found for the instructors.
create_table "instructors", force: true do |t|
  t.string   "first_name"
  t.string   "last_name"
  t.string   "handle"
  t.string   "google_plus"
  t.text     "bio"
  t.string   "avatar"
  t.datetime "created_at"
  t.datetime "updated_at"
end

# Procfile
web: bundle exec thin start -p $PORT
redis: redis-server redis.conf