诺曼,谢谢。我删除了 slug 列,但这并没有解决它。似乎默认 slug 覆盖了 update_attributes 处的 slug_se。
这是来自日志:
Started POST "/vardag/procent/result" for 127.0.0.1 at 2011-09-22 07:36:02 +0200
Processing by CalculationsController#result as HTML
Parameters: {"utf8"=>"Ô£ô", "authenticity_token"=>"Xrq9Zf8jGl2X1G9WvqMpcN1EQw7C2lda561FN9E7ZdM=", "first_number"=>"1.0", "second_number"=>
"2.5", "operation"=>"from_a_to_b", "commit"=>"Beräkna", "calculation_type_id"=>"vardag", "id"=>"procent"}
←[1m←[36mCalculation Load (1.0ms)←[0m ←[1mSELECT `calculations`.* FROM `calculations` WHERE (`calculations`.`slug_se` = 'procent') LIMIT
1←[0m
←[1m←[35mCalculationType Load (1.0ms)←[0m SELECT `calculation_types`.* FROM `calculation_types` WHERE (`calculation_types`.`id` = 1) LIMI
T 1
←[1m←[36mCACHE (0.0ms)←[0m ←[1mSELECT `calculations`.* FROM `calculations` WHERE (`calculations`.`slug_se` = 'procent') LIMIT 1←[0m
←[1m←[35mSQL (1.0ms)←[0m BEGIN
←[1m←[36mCalculation Load (1.0ms)←[0m ←[1mSELECT `calculations`.* FROM `calculations` WHERE (`slug_se` = 'percentage' OR `slug_se` LIKE '
percentage--%') AND (id <> 1) ORDER BY LENGTH(`slug_se`) DESC, `slug_se` DESC LIMIT 1←[0m
←[1m←[35mAREL (1.0ms)←[0m UPDATE `calculations` SET `recently` = 'someone_realized,that,when,1.0,goes_to,2.5,result_percentage_a_to_b_inc
reased,150.0,%', `slug_se` = 'percentage', `updated_at` = '2011-09-22 05:36:03' WHERE (`calculations`.`id` = 1)
查看@36mCACHE,它(正确地)使用 slug_se = procent,然后向下两行 @36mCalculation LOAD 它选择其中 slug_se = 百分比(百分比为 slug_en)。
我将在 Git 上写一个错误报告!
编辑:我做了一些可能有帮助的调试:
我在模型中使用此方法调用更新:
def update_recently(calculation, new_recently_string)
raise calculation.inspect
calculation.update_attributes(:recently => new_recently_string.join(","))
end
加薪创造了这个:
#<Calculation id: 1, name: "Percentage", preimp: nil, url: nil, clicks: 71, clicks_week: 71, is_local: true, comment: nil, nofollow: true, updated: nil, calculation_type_id: 1, created_at: "2011-03-12 07:04:54", updated_at: "2011-09-22 05:53:25", last_checked: nil, calculation_status_id: 2, region_id: 1, source: nil, affiliate: false, examples: nil, recently: "someone_realized,that,when,1.0,goes_to,2.5,result_p...", is_special: false, slug_en: "percentage", slug_se: "procent">
参数是:
{"utf8"=>"✓",
"_method"=>"put",
"authenticity_token"=>"Xrq9Zf8jGl2X1G9WvqMpcN1EQw7C2lda561FN9E7ZdM=",
"first_number"=>"1.0",
"second_number"=>"2.5",
"operation"=>"from_a_to_b",
"commit"=>"Beräkna",
"calculation_type_id"=>"vardag",
"id"=>"procent"}
我做了一个 raisecalculation.friendly_id.inspect 它显示“procent”。