난 내 레일 애플 리케이션 중 하나와 꽤 이상한 문제가 있어요. 아마 내가 어리석게 말하는 것을 알고있을 수는 없다. 제 문제는 인덱스 경로의 절반이 사라진 것 같습니다.레일 3 - 누락 된 인덱스 경로?
foos POST /foos(.:format) {:action=>"create", :controller=>"foos"}
을하지만 아무도 GET 옵션은 일반적으로 없을 것이다 : 내 컨트롤러는 "FOOS는"모델 foo에 대한 경우
예를 들어, 나는거야 아래
foos GET /foos(.:format) {:action=>"index", :controller=>"foos"}
내 누락 된 색인 경로를 복구 할 수 있도록 실제 코드를 보여 드리겠습니다.
routes.rb : 공지 사항 부분에 대한
resource :announcements, :controller => "announcements" do
resources :comments
member do
post 'vote'
end
end
경로 :
announcements POST /announcements(.:format) {:action=>"create", :controller=>"announcements"}
new_announcements GET /announcements/new(.:format) {:action=>"new", :controller=>"announcements"}
edit_announcements GET /announcements/edit(.:format) {:action=>"edit", :controller=>"announcements"}
GET /announcements(.:format) {:action=>"show", :controller=>"announcements"}
PUT /announcements(.:format) {:action=>"update", :controller=>"announcements"}
DELETE /announcements(.:format) {:action=>"destroy", :controller=>"announcements"}
더 GET/인덱스가없는 볼 수 있듯이. 내 컨트롤러에는 다음과 같이 정의 된 간단한 인덱스 메서드가 있습니다.
def index
@announcements = Announcement.all
respond_to do |format|
format.html
format.xml { render :xml => @announcements }
end
end
이 인덱스 경로가없는 이유는 실제로 이해가 가지 않습니다. 다른 여러 컨트롤러에서도 마찬가지입니다. 어떤 도움을 주시면 감사하겠습니다.
편집 : 콘솔에서 app.announcements_path는 메소드 누락 오류와 색인 경로가 누락 된 오류를 반환합니다.
감사합니다. 나는 어리석은 짓을 한 것을 알았습니다. 고마워요 ~ – Kombo
와우, 그 하나도 놓친 ... 고마워! –