2012-11-11 2 views
2

나는 다음과 같이 레일 '형태를 선택 도우미를 무시하려고 :Rails의 선택 양식 도우미를 재정의하는 방법은 무엇입니까?

def select(method, choices, options = {}, html_options = {}) 
    html_options.reverse_merge!(:disabled => true) 
    super(method, choices, options = {}, html_options = {}) 
end 

목표는 disable 모든 선택 태그입니다.

불행히도, 전혀 작동하지 않습니다. 선택 상자가 전혀 비활성화되지 않으며 오류도 표시되지 않습니다. 메서드가 제대로 호출되었는지 확인 했으므로 문제가 될 수 없습니다.

아무에게도 내가 누락 된 내용을 말할 수 있습니까?

모든 포인터 주셔서 감사합니다.

+0

죄송합니다. 실제로 작동하지 않는 점은 무엇입니까? – HungryCoder

+0

': disabled => "disabled"'시도 했습니까? – PinnyM

+0

방금 ​​했어요. 똑같이 작동합니다 ... – Tintin81

답변

1

옵션 옵션을 super로 보내면 재설정됩니다.

def select(method, choices, options = {}, html_options = {}) 
    html_options.reverse_merge!(:disabled => true) 

    # Don't do this! By doing this you're *always* sending empty objects for 
    # options and html_options to super. 
    #super(method, choices, options = {}, html_options = {}) 

    # Do this! 
    super(method, choices, options, html_options) 
end 
+0

그게 속임수 였어요, 덕분에 많은 도움을 얻었습니다! – Tintin81

관련 문제