我收到一條錯誤消息指出缺少 '顯示' 在Rails的模板
Missing template syndication/show, application/show with {:locale=>[:en], :formats=>[:text], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * "Projects/PlanoSyndication/app/views"
這裏是我的路線:
Rails.application.routes.draw do
get 'syndication/:name', to: 'syndication#show', defaults: {format: 'txt'}
end
這裏是我的模型:
class Syndication < ActiveRecord::Base
end
這裏是我的控制器:
class SyndicationController < ApplicationController
def show
@syndications = Syndication.find_by name: 'tour_urls.txt'
end
end
和views/syndication/show.html.erb
坐在
<div>
<%= @syndications.each do |syn| %>
<%= syn.body %>
<% end %>
</div>
任何幫助將不勝感激。這是一個非常簡單的問題,我只是很難找到它。
如何做'格式:txt'在那裏得到擺在首位? – meagar
如果包含'format :::txt',Rails只會查找.txt文件,而您的文件是'.html.erb',它是'format :::html',這是默認設置。 – hansottowirtz