2012-09-21 1 views
0

유방암 인식 월 (10 월)에 다른 로고를 사용하고 싶습니다 ... 매개 변수를 사용하여 테스트 할 로고가 좋으면 작동하도록 할 수 있습니다. 10 월 이전에 스너프까지. 분명히 잘못된 것을하고 있습니다!핑크색 로고를 표시하려면 10 월에 루비를 확인하십시오

컨트롤러 :

def breast_cancer_logo_month 
    if params[:breast_cancer_logo_month] || Time.current.month = 10 
    return true 
    end 
    false 
end 

보기 :

<% if breast_cancer_logo_month %> 
    #breast cancer logo 
<% else %> 
    #standard logo 
<% end %> 
+0

변화'Time.current.month = 10' Time.current.month의 =='에 대한 빠른 재에 대한 10' – Salil

답변

4

귀하의 breast_cancer_logo_month가 잘못된 것입니다. 당신은 당신이 2를 필요로 할 때 간단한 동등 물을 사용하고 있습니다. 동등한 하나가 오류를 발생시키는 값 Time.current.month을 다시 시도합니다.
조건에서 참 또는 거짓을 반환하면 조건을 반환 할 수 있습니다. 그리고 당신은? 메소드 이름에도.

def breast_cancer_logo_month? 
    !!params[:breast_cancer_logo_month] || Time.current.month == 10 
end 

<% if breast_cancer_logo_month? %> 
    #breast cancer logo 
<% else %> 
    #standard logo 
<% end %> 
+0

감사합니다 !!!! 이 방법은 컨트롤러에서 사용됩니까? 정의되지 않은 메소드'breast_cancer_logo_month? '가져 오기 – jahrichie

+0

찾았습니다! helper_method로 추가해야했습니다 : breast_cancer_logo_month? – jahrichie

+0

'breast_cancer_logo_month? '가 컨트롤러가 아니라 도우미에 있어야합니다. – oldergod

관련 문제