2

덮어 쓰기 :는 - Friendly_id 4.0.0 베타 11 - - 윈도우 - 국제화에 따라 (0.6.0, 0.5.0) "보석 목록 3.0.3 레일 "는 사용

설정 : 언어로 스웨덴어와 영어를 사용하는 계산에 대한 다국어 웹 사이트가 있습니다. 친절한 URL을 생성하기 위해 friendly_id를 사용하고 있습니다.

내 mysql 테이블에는 "slug", "slug_se"및 "slug_en"열이 있습니다. 나는 "슬러그"컬럼을 사용해야하는지 잘 모르겠다. "슬러그"컬럼과 동일하다.

문제 : "update_attributes는"그것 (기본적으로 영어로) "슬러그"와 "slug_se"를 덮어 사용하는 동안. 따라서 "slug"의 값은 "slug_se"에 기록됩니다.

트러블 슈팅 : -이 문제를 봤 만 구글 포럼에 하나 (답) 포럼 스레드를 발견했다 (http://groups.google.com/group/friendly_id/browse_thread/thread/154f4a5024e23418)이 답이 없다. - 나는 update_attributes에 대한 대안을 찾으려고 노력했다. mysql을 통과 할 수는 있었지만 정말 깔끔하지는 않다.

질문 : - "슬러그"열을 사용해야합니까? - update_attributes 대신 ID를 업데이트하지 않는 대안이 있습니까? - 내가하는 일에 문제가있는 것을 볼 수 있습니까?

코드 : 모델 :

extend FriendlyId 
    friendly_id :name, :use => :slugged, :use => I18n 

답변

3

내가 FriendlyId의 저자입니다. 프로젝트에 대한 Github 문제에서이 질문을하는 것이 더 나을 것입니다. 우연히 우연히 만났습니다.

i18n 모듈은 여전히 ​​매우 새롭습니다. 불안정한 점에 대해 사과드립니다. 의견에 감사드립니다. :)

슬러그 열에 관한 질문에 대한 답변을 제공 할 필요는 없습니다. 단지 slug_en과 slug_se뿐입니다.

https://github.com/norman/friendly_id/commit/54536464132ac8f72c96e8bda203c337f9d56aa0

그래서 그 열을 제거하는 노력이 9 월 4 일에 적용한 변경 내용을이었다. 문제가 지속되면 Github에 버그 보고서를 게시 해주십시오. 가능한 한 빨리 살펴 보겠습니다.

당신이 설명하는 문제를 재현하려는 시도를 추가하는 한편, 그것을 재현 할 수 있다면 확실히 고칠 것입니다.

0

노먼, 감사합니다. 나는 슬러그 컬럼을 제거했다. 그러나 이것으로 해결하지는 못했다. 기본 슬러그가 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 = %가 당신의 행동이 군주제를 다음 @ 36mCalculation는 선별 된 곳 slug_se = 비율 (백분율 존재의 slug_en하게 LOAD 두 행 아래로).

힘내에서 버그 리포트를 작성하겠습니다!

편집 :

내가 모델이 방법 업데이 트 전화 : 내가 도움이 될 수있는 몇 가지 더 디버깅했다

#<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"> 
: 인상

def update_recently(calculation, new_recently_string) 
    raise calculation.inspect   
    calculation.update_attributes(:recently => new_recently_string.join(",")) 
    end 

이 생성

매개 변수는 다음과 같습니다.

{"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"} 

나는 calculate.friendly_id.inspect를 올렸고 "procent"를 보여주었습니다.