2013-03-22 5 views
0

모델 :이 도우미는 어떻게 작동합니까?

Group: 
has_many :booth_marketing_messages, :dependent => :destroy 

Booth Marketing Message: 
belongs_to :group 

경로 :

resources :groups do 
     member do 
     get :get_group_links 
     get :booth_marketing_messages 
     end 
     resources :booth_marketing_messages do 
     member do 
      match :toggle_activation 
     end 
     end 
    end 

내가 가진보기가 새로운 부스 마케팅 메시지의 작성 :

 booth_marketing_messages_group GET /groups/:id/booth_marketing_messages(.:format)           
    {:action=>"booth_marketing_messages", :controller=>"groups"} 

     group_booth_marketing_messages GET 
    /groups/:group_id/booth_marketing_messages(.:format)         
    {:action=>"index", :controller=>"booth_marketing_messages"} 
:

<% form_for :asset, :url => (defined?(msg) ? group_booth_marketing_message_path(msg) :   
     group_booth_marketing_messages_path), :html => { :multipart => true, :method => 
     (defined?(msg) && msg ? :put : :post) } do |f| -%> 
      ....... 

내가 레이크 경로를 실행하는 경우를

그러나 내 부스 마케팅 메시지 컨트롤러에는 색인 작업이 없습니다. 네,이 길은 실패하지 않습니다, 그게 어때요?

resources :booth_marketing_messages do 
    member do 
     match :toggle_activation 
    end 
    end 

답변

1

당신이 쓴 노선 그래서 인덱스, 새, 생성, 갱신, 파괴, 편집으로 기본 경로를 생성하고 컨트롤러에서 언급 된 모든 행동이 관계없이 표시하거나이 있더라도 컨트롤러 없음.

하지만 그 URL로 이동하면 오류가 발생하거나 컨트롤러가 표시되지 않습니다.

기본 경로를 사용하고 싶지 않거나 사용하지 않으려면 경로 예를 들어서 만 사용할 수 있습니다.

resources :products, only: [:new] 

이것은 단지 새로운 액션에 대한 경로를 생성하고

resources :products, except: [:new] 

이이 만드는 희망은 당신이 명확

+0

난 당신이 sayign 무엇인지 이해하는 새로운 액션을 제외한 모든 경로를 작성합니다 그러나 "당신이 그 URL로 갈 때 당신은 발견되지 않은 행동의 오류를 갖거나 컨트롤러는 존재하지 않을 것입니다." - 그게다고, 나는 BoothMarketingMessagesController에 대한 색인 작업/색인보기가 없지만 '새로운'작업의 양식에서 언급 한 URL은 어떤 오류도 발생시키지 않습니다 ... 왜 오류를 던지지 않았는지 알고 싶습니까? – user1865578

+0

브라우저에 해당 URL을 입력하면 "알 수없는 작업"과 같은 오류가 표시되지 않습니다. 그래서 대신 무엇을 얻는거야? 어떤 페이지? – jbmyid

+0

예는 오류를 던지고되지 않지만 대신 GET booth_marketing_messages_group – user1865578