내가 처음으로 응용 프로그램에 유증을 사용하고 내가 이해하지 못할 이상한 문제가 있습니다와 혼합하기 모든 등록, 사용자 가입 등을 설정하면 모든 것이 잘 작동합니다. 내 응용 프로그램 헤더에서, 내 탐색 (현재 비어) 메뉴에서 로그가있는 부분을 가지고, 등, 로그 아웃 :고안 링크/경로가 아닌 유증 모델
_header.html.erb
<div class='topbar'>
<div class='container'>
<%= link_to 'My app', root_path, :class => 'brand' %>
<div class='nav'>
</div>
<%= render 'layouts/user_options' %>
</div>
</div>
_user_options.html.erb
<%= link_to 'Tasks', '/tasks/index' %>
다 : 내가 사용하는 경우
<ul class='user-options'>
<% if user_signed_in? %>
<li><%= link_to "Signed in as #{current_user.username}", '#' %></li>
<li><%= link_to "Sign out", destroy_user_session_path, :method => :delete %></li>
<% else %>
<li><%= link_to "Sign up", new_user_registration_path %></li>
<li><%= link_to "Sign in", new_user_session_path %></li>
<% end %>
</ul>
는 지금은 탐색 메뉴에 첫 번째 링크를 추가하고 괜찮습니다. 하지만 내가 사용하는 경우 :
<%= link_to 'Tasks', :controller => 'tasks', :action => 'index' %>
때 나는 그런 '로그인'으로 고안 링크의 클릭, 내가 코멘트에 요청하여
'No route matches {:controller=>"devise/tasks"}'
를 얻을, 여기 rake routes:
작업의 출력은 : TOP => 루트 => 환경 (--trace와 작업을 실행하여 전체 추적을 참조하십시오) 맥북 프로 - 드 - 오 : 여기 dearsherpa 오스카 $ 번들 간부 레이크 노선
tasks_index GET /tasks/index(.:format) {:controller=>"tasks", :action=>"index"}
tasks_show GET /tasks/show(.:format) {:controller=>"tasks", :action=>"show"}
new_user_session GET /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
user_session POST /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session DELETE /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
user_password POST /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_user_password GET /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_user_password GET /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"}
cancel_user_registration GET /users/cancel(.:format) {:action=>"cancel", :controller=>"devise/registrations"}
user_registration POST /users(.:format) {:action=>"create", :controller=>"devise/registrations"}
new_user_registration GET /users/sign_up(.:format) {:action=>"new", :controller=>"devise/registrations"}
edit_user_registration GET /users/edit(.:format) {:action=>"edit", :controller=>"devise/registrations"}
PUT /users(.:format) {:action=>"update", :controller=>"devise/registrations"}
DELETE /users(.:format) {:action=>"destroy", :controller=>"devise/registrations"}
root / {:controller=>"pages", :action=>"home"
및 경로입니다. rb :
get "tasks/index"
get "tasks/show"
devise_for :users
root :to => 'pages#home'
왜 이가 ?? 내가 뭘 잘못하고 있니?
편집 2 : 그런데 나는 Task belongs_to User
을 언급하는 것을 잊어 버렸고 사용자 모델은 devise에 의해 생성되었습니다. 아마 그 원인이 무엇일까요?/user/id/tasks /가없이/tasks/index에 액세스 할 수 없습니까?
편집 : 더 이상한 물건, 내가 리소스를 사용하여 시도 : 대신 해당 컨트롤러에 대한 '도착'노선의 내 루트 파일에서 작업을하고, 내가 <%= link_to 'Tasks', :controller => 'tasks', :action => 'index' %>
를 클릭하면 이제 show 액션 날을합니다. 분명히 내 길에 뭔가 잘못되었습니다.
run : 여기에서 결과를 레이크하고 복사하여 붙여 넣으십시오. – daniel
routes.rb에서 코드를 게시하고'rake routes'를 실행할 수 있습니까? – stephenmurdoch
완료, 내 질문을 편집했습니다. –