이것은 매우 어리석은 질문 일 수 있습니다. 나는 Ruby를 처음 사용하기 때문에 내가하는 일을 전혀 모른다. application.html.erb에 레이아웃을 설정 중입니다. 내 탐색 용 링크 중 하나는 이력서의 기본 표시 페이지로 연결됩니다. 아마 쇼 대신 인덱스로 설정해야합니다. 그러나 그것을 시도했을 때, 상황은 더욱 혼란스러워졌습니다. 내가 현재 가지고있는 코드와Ruby on Rails UrlGenerationError
은 내가지고있어 오류가
Showing thisSectionOfUrlTakenOut/app/views/layouts/application.html.erb
where line #22 raised:
No route matches {:controller=>"resume", :action=>"show"} missing required keys:
[:id]
Extracted source (around line #22):
19 <ul>
20 <li><%= link_to "Home", welcome_index_path %></li>
21 <li><%= link_to "Projects", projects_path %></li>
22 <li><%= link_to "Resume", resume_path, method => show %></li>
23 <li><%= link_to "Blog", posts_path %></li>
24 </ul>
25 </nav>
은 그대로, 내 application.html.erb는 다음과 같습니다이다.
<!DOCTYPE html>
<html>
<head>
<title>Portfolio</title>
<%= stylesheet_link_tag "application", media: "all",
"data-turbolinks-track" => true %>
<%= javascript_include_tag "application",
"data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
<body>
<header>
<% if current_user %>
<h1>Welcome</h1>
<%else%>
<h1> Portfolio</h1>
<%end%>
<nav>
<ul>
<li><%= link_to "Home", welcome_index_path %></li>
<li><%= link_to "Projects", projects_path %></li>
<li><%= link_to "Resume", resume_path, method => show %></li>
<li><%= link_to "Blog", posts_path %></li>
</ul>
</nav>
</header>
<%= yield %>
<footer>
<% if !current_user %>
<%= link_to "Login", admin_console_index_path%>
<% else %>
<%= link_to "Logout", destroy_user_session_path, :method => :delete%>
<%end%>
</footer>
</body>
</html>
routes.rb는
같은Portfolio::Application.routes.draw do
devise_for :users
resources :posts do
resources :comments
end
resources :projects
resources :resume
resources :admin_console
resources :welcome
root 'welcome#index'
end
보이는 내가 고안 사용하기 시작하면
class ResumeController < ApplicationController
def show
end
end
도움이된다면
는, 몇 가지 문제가 시작처럼 resume_controller.rb 보인다. 하지만 그때 이후로 나는 다른 오류가 상황을 악화 시켰다고 생각합니다. 어떤 도움을 주셔서 고맙게 생각합니다. 설명해 주시면 더 좋을 겁니다.
DB에 여러 개의 이력서를 저장 하시겠습니까? 아니면 자신 만의 개인 웹 사이트를 보여줄 개인 웹 사이트입니까? – jstim
이력서를 웹 사이트의 양식을 통해 작성 했습니까? html로 직접 작성 했습니까? –
리소스는 id가 특정 이력서를 보여줄 것으로 기대하고 있습니다 @jstim askes 당신은 1보다 많을 것입니까? 아니면 당신의 이력서를 보여주기를 원하십니까? 이전 버전 인 경우 resume 객체 (또는 resume_path에 ID)를 전달해야합니다. – Doon