Template is missing.... but it is there!

Hello friends!
I have an application to list different kinds of institution names. So
I have one table “instits” for the institutions and another table
“nome_instits” for their names. For test, I put two rows inside
“instits” and three names for the first institution and two names for
the last. Then I created this controller:

class ServInstitController < ApplicationController

def index
@instit = Instit.find(:all, :order => ‘created_at asc’)
end

def shownames
instit_ident = params[:instit_id]
@nomesinstit = NomeInstit.find_all_by_instit_id(instit_ident)
end

end

And I created this view “index”:

Serviços relacionados à instituições


<% if @instit.nil? == false and @instit.length > 0 %>
<% @instit.each do |instit| %>
  <tr>
    <td><%=h instit.id %></td>
    <td><%=h instit.descricao %></td>
    <td><%=h NomeInstit.find(:first, :conditions =>

[“instit_id= ?”, instit.id]).descricao %>



<% end %>

ID Descrição Nome
<%= link_to ‘Ver outros
nomes’, :action=> :shownames, :instit_id => instit.id %>
<% else %> Nenhuma instituição encontrada! <% end %>
<%= link_to 'Voltar', :controller => :pp_administracao %>

So I created this view “shownames”:

<% @nomesinstit.each do |nomesinstit| %>
  <tr>
    <td><%=h nomesinstit.id %></td>
    <td><%=h nomesinstit.descricao %></td>
  </tr>
<% end %>
ID Descrição Nome




<%= link_to ‘Voltar’, :controller => :serv_instit, :action => :index
%>

Well. Then I can see the following screen:
ID
Descrição
Nome
1 Instituição onde está instalado este SIGAD
FUB Ver outros nomes
3 Órgão do Governo responsável pelas universidades
MEC Ver outros nomes

Voltar

When I, for example, put the mouse pointer over the second “Ver outros
nomes”, I can see this generated url:

http://localhost:3000/serv_instit/shownames?instit_id=3

Hmmm, I don’t know if this is a valid url. “instit_id” is the foreign
key in the table “nome_instits” pointing to the correct row in the
table “instits”, and the value “3” is correct. When I click over there
I get this error:

Template is missing

Missing template serv_instit/shownames with
{:handlers=>[:rxml, :builder, :erb, :rjs, :rhtml], :formats=>[:html],
:locale=>[:en, :en]}
in view paths “/home/luiz/work/sigad3/app/views”, “/home/luiz/work/
sigad3/vendor/plugins/jrails/app/views”, “/usr/lib/ruby/gems/1.8/gems/
devise-1.1.rc1/app/views”

I tried insert these rows in the routes file, but it didn’t work:

resources :serv_instits

get “serv_instit/shownames”

get “serv_instit/index”

Could someone help me?
Thank you very much!!

Mr Colin,
When I looked for the full path and filenames for the views to give to
you, I saw that the shownames filename was incorrect: ~/views/
serv_instit/_shownames.html.erb. Before I was trying to use a
partial… Then I changed the filename to /shownames.html.erb and the
application worked!!
Thank you, very very much!

On 9 July 2010 18:24, LuisRuby [email protected] wrote:

@instit = Instit.find(:all, :order => ‘created_at asc’)

<% end %> Nome

http://localhost:3000/serv_instit/shownames?instit_id=3

Hmmm, I don’t know if this is a valid url. “instit_id” is the foreign
key in the table “nome_instits” pointing to the correct row in the
table “instits”, and the value “3” is correct. When I click over there
I get this error:

The ?instit_id=3 is there because in the link you have specified
:instit_id => instit.id thereby requesting instit_id to be included as
a parameter

Template is missing

Missing template serv_instit/shownames with
{:handlers=>[:rxml, :builder, :erb, :rjs, :rhtml], :formats=>[:html], :locale=>[:en, :en]}
in view paths “/home/luiz/work/sigad3/app/views”, “/home/luiz/work/
sigad3/vendor/plugins/jrails/app/views”, “/usr/lib/ruby/gems/1.8/gems/
devise-1.1.rc1/app/views”

The fact that it is complaining about a missing template suggests that
it has successfully gone to the shownames action and is trying to
render the result. Maybe you have an error in the path or filename
for the view file. Can you supply the full path and filenames for the
controller and view files please?

Colin