0

I am getting an error message stating

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"

Here is my Route:

Rails.application.routes.draw do

    get 'syndication/:name', to: 'syndication#show', defaults: {format: 'txt'}

end

Here is my model:

class Syndication < ActiveRecord::Base
end

Here is my Controller:

class SyndicationController < ApplicationController

  def show
    @syndications = Syndication.find_by name: 'tour_urls.txt'
  end

end

and in views/syndication/show.html.erb sits

<div>
  <%= @syndications.each do |syn| %>
    <%= syn.body %>
  <% end %>
</div>

Any help would be greatly appreciated. This is a very simple problem, I am just having real trouble finding it.

Mostafiz
  • 7,243
  • 3
  • 28
  • 42

2 Answers2

2

I think it's the defaults: {format: 'txt'} option that's causing the lookup to fail.

You can see in this error:

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"

That the "formats" list doesn't contain html. You could remove the defaults option and the lookup should succeed if your files are placed & named correctly.

max pleaner
  • 26,189
  • 9
  • 66
  • 118
0

NO need to have defaults: {format: 'txt'} in your routes.rb