试图呈现不同的布局,但得到nomethod错误
问题描述:
试图这样做是为了使不同的布局:试图呈现不同的布局,但得到nomethod错误
class LocationsController < ApplicationController
render layout "locations"
有在布局相应的locations.html.erb文件和位置文件夹包含索引和显示文件。
我的位置布局文件很简单:
<!DOCTYPE html>
<html>
<head>
<title>locations layout</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<div class="ui menu">
<%= link_to "Counties", counties_path, :class => "active item"%>
<%= link_to "About Us", about_path, :class => "item"%>
</div>
<%= yield %>
</body>
</html>
我得到这个错误和唐;知道为什么:
undefined method `render' for LocationsController:Class
我所有的路线错误消息还列出并作为如下:
resources :counties do
resources :locations
end
root 'home#index'
get '/about' => "home#about"
get "/:location_name_with_prefix" => "locations#show_by_location_name"
答
你应该只调用
layout "locations"
这样,删除“渲染”
答
没有必要把渲染关键字。只使用 layout 'locations'
它应该工作
+0
谢谢@LHH我没有;不知道如何分开答案,因为他们都是相同的,都是正确的! – user3735114 2014-10-07 18:36:49
啊,当然,谢谢! – user3735114 2014-10-07 17:04:15