2017-02-11 1 views
0

만료 된 스페셜이있는 레일 앱을 만듭니다. 누군가가 로그온 할 때마다 이미 만료 된 스페셜을 찾는 Def가 있습니다. 그것은 로컬에서 잘 작동하지만 내가 Heroku가에 배포 할 때이 오류가 얻을 :Heroku PostgreSQL에서 "<="연산자를 사용할 때 오류가 발생합니다.

ActiveRecord::StatementInvalid (PG::UndefinedFunction: ERROR: operator does not exist: character varying <= numeric 

와 힌트 : 여기에

HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. 

내가 만든 데프입니다. 나는

def check_expired 
    time = DateTime.now.to_f.to_s 
    @specials = Special.where("expires <= #{DateTime.now.to_f.to_s}") 
    @specials.destroy_all 
end 

답변

0

이하자 레일 당신을 위해 날짜를 처리하고이

@specials = Special.where('expires <= ?', Time.zone.now) 

하거나 ...

@specials = Special.where('expires <= NOW()') 
처럼 수행 데프에 대한 응용 프로그램 컨트롤러에 before_filter 추가
관련 문제