2014-04-14 5 views
3

나는 인덱스 페이지를로드하려고하면이 오류가 계속 : 나는 ApplicationControllerBaseController를 교체 할 경우웹 소켓 클래스

NoMethodError in MessageController#new_message 
undefined method `action' for MessageController:Class 

오류가 사라질를, 하지만 이것 역시 많은 것들을 망가 뜨리고 rails-websocket을위한 튜토리얼 (http://websocket-rails.github.io/)은 BaseController으로되어 있습니다.

class MessageController < WebsocketRails::BaseController 

    def initialize_session 
    # perform application setup here 
    controller_store[:message_count] = 0 
    end 

    def new_message 
    new_message = {:message => 'this is a message'} 
    send_message :new_message, new_message 
    end 

    def index 

    end 
end 

누구에게 어떤 문제가 있는지 알고 있습니까?

- 편집 사용하여 레일 버전 4.0.2 그 모든

+0

어떻게 액세스하고 있습니까? –

+0

비슷한 문제가 있습니다. WebsocketRails :: BaseController에 대한 다른 컨트롤러를 사용하여 websocket 이벤트를 처리했습니다. 인덱스, 생성 등의 경로와 관련이 있다고 생각합니다. WebsocketRails :: BaseController가 라우트 요청을 처리 할 수 ​​없다고 생각합니다. 그리고 아마 당신이 제공 한 참조 링크에있는'create '는 실제로'create'하지만 실제로 REST 메서드는 아닙니다. 그렇지 않으면, 레일 4.0.2와 호환되지 않을 수도 있고, 버그 일 수도 있습니다. 누군가가 대답 할 수 있기를 바랍니다. –

답변

1

에서 중요한이 과거에 프로젝트의 이슈 트래커에 reported as an issue 계속 것처럼 보이지만 (비 수정과) 폐쇄 된 경우 . 상황을 설명

주석은 :

You don't want to mix ApplicationController methods with ones from WebsocketRails::BaseController. In fact, WebsocketRails::BaseController is designed after ApplicationController and implements some of the same methods, namely process_action.

내가 사용하는 (그리고 그들은 또한 제안)이 솔루션, 2 컨트롤러를 사용하는 것입니다. 하나는 WebsocketRails :: BaseController에서 상속 받고 다른 하나는 ActionController :: Base (Rails)에서 상속합니다. 로직을 별도의 클래스에 넣고 둘 다에서 사용하십시오.