2
我并不确定此系统是否缓存数据,但它具有一些缓存特性。Rails 3.2.4 SQL查询缓存结果查找(:所有)
基本上我搞乱了rails 3.2.4,系统开始不显示一些结果。我认为这对于我放入代码模型的默认范围是露水的,但即使如此,它也应该显示所有结果,而不是9个中的10个。但是,我总是会缺少我创建的新记录以及我创建的任何其他记录那个纪录。我检查了我的sqlite3数据库,看看数据是否放在那里,并检查所有的连接信息,并确保缓存关闭。但是,如果我更改了任何模型文件或控制器文件,然后保存它,我可以获取数据。甚至不会改变代码,只是触摸命令可以做到这一点。我认为这与范围有关,但我不能确定。我找到的一个解决方案就是回到Rails 3.2.2。它接近要做的伎俩。但我仍然不喜欢像我刚刚屈服的感觉一样去解决这个问题。
development.rb
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
house.rb
class House < ActiveRecord::Base
attr_accessible :name
default_scope :order => 'created_at DESC', :limit => 50
validates_presence_of :name
has_many :roomies
end
schema.rb
ActiveRecord::Schema.define(:version => 20120601204050) do
create_table "houses", :force => true do |t|
t.string "name"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end
houses_controller.rb
class HousesController < ApplicationController
def index
@houses = House.all
end
def new
@house = House.new
end
def show
@house = House.find(params[:id])
end
def create
@house = House.new(params[:house])
if @house.save
flash[:success] = "Your house has been created and is ready to have people added to it."
redirect_to houses_path
else
flash[:error] = "Your house could not be added dew to a error!"
render :action => :new
end
end
end
个
房子/ index.html.erb
<%= debug @houses %>
正如你可以看到什么超级疯狂。
甜蜜感谢您的答案这真的有帮助 – Brandt