看起来像Rails做缓存,我不希望它

时间:2013-06-13 15:11:29

标签: ruby-on-rails

@avalibable_colors=['#5A009D', '#004DFF', '#F4F400', '#FF8000']变量(它不是模型的实例),它代表了可用的选项 - 颜色,尚未采用的方法,通过方法:

def choose_color
  @check=Check.find(params[:check_id])
  @colorschemes=@check.colorschemes
  current_colors=[]
  @check.colorschemes.each do  |c|
    current_colors.push(c.color)
  end
  @avalibable_colors=['#5A009D', '#004DFF', '#F4F400', '#FF8000']
  current_colors.each do |c|
    if @avalibable_colors.index(c)
      @avalibable_colors[@avalibable_colors.index(c)]=nil
    end
  end
  @avalibable_colors.compact!
  respond_to do |format|
    format.js
  end
end

之后@avalibable_colors内容仅取消了颜色选项。

一般来说它都有效。如果我选择1种颜色选项,它会显示休息4,如果是2 - 休息3,如果我选择一种,然后删除它 - 它是可用的颜色。

直到整整四个都有效。如果我添加所有四个,然后逐个删除,则在我刷新页面之前,没有颜色可用

服务器日志:

Started GET "/choose_color?check_id=46" for 127.0.0.1 at 2013-06-13 19:00:31 +0400
Processing by ColorschemesController#choose_color as JS
  Parameters: {"check_id"=>"46"}
  User Load (1.0ms)  SELECT "users".* FROM "users" WHERE "users"."auth_token" = 'oPXJtztDkYdYmVsQ3wxxfQ' LIMIT 1
  Check Load (1.0ms)  SELECT "checks".* FROM "checks" WHERE "checks"."id" = 46 LIMIT 1
  CACHE (0.0ms)  SELECT "checks".* FROM "checks" WHERE "checks"."id" = 46 LIMIT 1
  Check Load (1.0ms)  SELECT "checks".* FROM "checks" WHERE "checks"."id" = $1 LIMIT 1  [["id", "46"]]
  Colorscheme Load (0.0ms)  SELECT "colorschemes".* FROM "colorschemes" WHERE "colorschemes"."check_id" = 46
  Rendered colorschemes/_choose_color.html.erb (0.0ms)
  Rendered colorschemes/choose_color.js.erb (5.0ms)
Completed 200 OK in 33ms (Views: 22.0ms | ActiveRecord: 3.0ms)

0 个答案:

没有答案