【发布时间】:2014-08-26 21:04:46
【问题描述】:
我已经从 https://github.com/lockitron/selfstarter 克隆了 repo,我正在尝试在标题中创建指向新页面的链接,但链接没有显示
我想在标题中创建一个“探索”按钮,所以我创建了一个资源管理器控制器和模型运行迁移并在标题部分中使用 link_to 辅助方法来创建链接到页面的新按钮,但它没有显示出来。如何做我显示了我的“探索”按钮,该按钮链接到资源管理器文件夹中的“show.html.erb 页面”
routes.rb
resources :explorer
explorer_controller
class ExplorerController < ApplicationController
def show
end
end
show.html.erb
<p> hello </p>
header.html.erb
<div id="header">
<%= link_to 'Explore, explore_path %>
</div>
我也收到以下错误
ActionController::UrlGenerationError in Preorder#index
Showing /Users/views/preorder/_header.html.erb where line #2 raised:
No route matches {:controller=>"explorer", :action=>"show"} missing required keys: [:id]
Extracted source (around line #2):
1 <div id="header">
2 <%= link_to 'Explore', explorer_path %>
3 <div class="wrapper clearfix">
4 <h1 id="lockitron_header"><a href="/"><%= Settings.product_name %></a></h1>
Trace of template inclusion: views/layouts/application.html.erb
Application Trace | Framework Trace | Full Trace
app/views/preorder/_header.html.erb:2:in `_app_views_preorder__header_html_erb___3778671432332580621_70190937023480'
app/views/layouts/application.html.erb:15:in `_app_views_layouts_application_html_erb___270280154590328587_70190919949800'
【问题讨论】:
-
这是一个错字还是你真的错过了一个结束
'in : -
另外,你是否在你的应用布局中渲染
header.html.erb? -
rb512 我错过了逗号,我添加了它。JTG 我在应用程序布局中呈现 header.html.erb。我仍然看不到按钮,我也因为缺少必需的键而收到错误
标签: html ruby-on-rails ruby