2011-03-29 3 views
2

resources :usersroutes.rb에 사용하고 있습니다. 이것은 rake routes가 공개 한대로 다음과 같은 경로를 제공합니다.자원의 명명 된 경로가 페이지 삭제 대신 페이지 표시로 전환됩니다.

users  GET /users(.:format)   {:action=>"index", :controller=>"users"} 
      POST /users(.:format)   {:action=>"create", :controller=>"users"} 
new_user GET /users/new(.:format)  {:action=>"new", :controller=>"users"} 
edit_user GET /users/:id/edit(.:format) {:action=>"edit", :controller=>"users"} 
user  GET /users/:id(.:format)  {:action=>"show", :controller=>"users"} 
      PUT /users/:id(.:format)  {:action=>"update", :controller=>"users"} 
      DELETE /users/:id(.:format)  {:action=>"destroy", :controller=>"users"} 

또한 기존의 야생 컨트롤러 경로를 주석 처리합니다.

#match ':controller(/:action(/:id(.:format)))' 

내가 다음을 추가 내 사용자 페이지에 삭제 링크를 추가합니다.

<%= link_to "Delete user", user, :method => :delete, :confirm => "Are you sure?" %> 

다음과 같은 html 코드가 생성되었습니다.

<a href="https://stackoverflow.com/users/42" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Delete user</a> 

나는 링크를 클릭하고는 에 저를 페이지를 표시합니다! 뭐가 문제 야? 즉, 제대로 작동하는

답변

5

당신은 기본 자바 스크립트 파일을 포함해야합니다

<%= javascript_include_tag :defaults %> 
관련 문제