加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails-3 – 帮助调试我的会话? Rails 3 ActionDispatch

发布时间:2020-12-16 19:44:38 所属栏目:百科 来源:网络整理
导读:即使我很确定我知道为什么这个错误被提升,我似乎不知道为什么或如何我的会话超过4KB限制… 我的应用程序工作正常,但一旦我故意开始添加错误,看看我的交易是否回滚我开始收到这个错误. 为了给一些背景,我正在忙着编写一个锦标赛的应用程序(在本节中)将创建比
即使我很确定我知道为什么这个错误被提升,我似乎不知道为什么或如何我的会话超过4KB限制…

我的应用程序工作正常,但一旦我故意开始添加错误,看看我的交易是否回滚我开始收到这个错误.

为了给一些背景,我正在忙着编写一个锦标赛的应用程序(在本节中)将创建比赛,然后根据球队数量添加一些比赛腿,并且通过一些“鬼魂装置”填充比赛腿已经创建

闪光[:锦标赛]之前工作正常;使用比赛对象,我可以访问任何AR验证错误以及在上一页输入的数据来创建比赛.

TournamentController.rb

begin
  <other code>
  Tournament.transaction do
    tournament.save!
    Tournament.generate_legs tournament
    Tournament.generate_ghost_fixtures tournament
  end

  flash[:notice] = "Tournament created!"
  redirect_to :action => :index
rescue Exception => e
  flash[:tournament] = tournament
  redirect_to :action => :new,:notice => "There was an error!"
end

Tournament.rb

self.generate_ghost_fixtures(tournament)
  <other code>
  #Generate the ghost fixtures
  #tournament_legs is a has_many association
  tournament_legs_array = tournament.tournament_legs

  tournament_legs_array.each do |leg|
    number_of_fixtures = matches[leg.leg_code]

    #For the first round of a 32 team tournament,this block will run 16 times to create the matches
    number_of_fixtures.times do |n|
      Fixture.creatse!(:tournament_leg_id => leg.id,:match_code => "#{leg.leg_code}-#{n+1}")
    end
  end
end

我只能猜测为什么我的会话变量超过4KB?
我通过Flash变量的比赛对象有可能还包含所有关联吗?

一旦我收到错误,这是我的会话转储.

希望这是足够的信息来帮助我:)

谢谢

会话转储

_csrf_token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
flash: {:tournament=>#<Tournament id: nil,tournament_name: "asd",tournament_description: "asdasd",game_id: 1,number_of_teams: 16,start_date: "2011-04-30 00:00:00",tournament_style: "single elimination",tournament_status: "Drafting",active: true,created_at: "2011-04-30 10:07:28",updated_at: "2011-04-30 10:07:28">}
player_id: 1
session_id: "4e5119cbaee3d5d09111f49cf47aa8fa"

解决方法

关于依赖,这是可能的.还会在会话中保存ActiveRecord实例不是推荐的aproach.你应该只保存id.如果您需要所有请求,请使用之前的过滤器来检索它.

你可以阅读更多为什么是一个坏主意:http://asciicasts.com/episodes/13-dangers-of-model-in-session

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读