DoubleRenderError가 계속 발생하며 이유를 파악할 수 없습니다! 기본적으로, 사용자가 입력 한 쿼리에서 오류를 검사하는 다른 동작을 호출하는 동작이 있으며 오류가 발생하면 해당 동작이 중지되고 오류가 표시됩니다. 하지만 오류가있는 쿼리를 입력하면 이중 렌더링이 실행됩니다. 어떤 욕설?이 작업에서 렌더링 및/또는 리디렉션이 여러 번 호출되었습니다 ..?
Heres는 오류 검사기 조치 :
def if_user_formulated_request_properly
unless request.post?
flash[:error] = "This page can only be accessed through the search page. (POST request only)"
redirect_to(:action => "index") and return
end
if params[:query].blank?
flash[:error] = "Search criteria can not be blank"
redirect_to(:action => "index") and return
end
if !(params[:query] =~ /-/)
flash[:error] = "(Format of search criteria is wrong.<br /> Should be [IXLSpecClass value][year]-[Message ID] for exam
ple GP07-8)"
redirect_to(:action => "index") and return
end
if !(QueryParser.expression.match(params[:query]))
flash[:error] = %(Format of search criteria is wrong.<br />Should be [IXLSpecClass value][year]-[Message ID] for examp
le GP07-8)
redirect_to(:action => "index") and return
end
yield
그리고 단지의 경우이 작업을 호출하는 작업이 필요합니다 ..
def show
if_user_formulated_request_properly do
@statuses = IXLStatus.find(:all)
@input_messages = InputMessage.search_by(params[:query].stri
p) unless params[:query].blank?
@query = params[:query]
end
respond_to do |format|
format.html #default rendering
end
end
end
UPDATE는
또한,이 얘기를 깜빡 했네요 원래 레일 2 응용 프로그램이었고,이 오류는 내가 레일 3 (내가 믿는다)로 업그레이드했을 때 시작되었다. 그래서 아마 레일 3은 일부를 수행한다. and return
와 다른 것?
먼저 어떤 행동 문제를합니까? 원래 주문과 변경 사항을 남겨 두었 기 때문에'undefined method '를 얻었습니다. if_user_formulated_request_properly'' –
메소드의 이름을 변경하여 명확하게 만들었습니다. 이제는'user_formulated_request_properly? '가되었습니다. –
자신을 바로 잡을 수 있어야합니다 :) 어쨌든 완벽한 근무 .. 감사합니다 무리 –