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

**URL:** <https://www.ruby-forum.com/t/template-is-missing-but-it-is-there/191342>\
**Category:** Rails\
**Created:** [July 9, 2010, 9:29pm UTC](https://www.ruby-forum.com/t/template-is-missing-but-it-is-there/191342 "2010-07-09T21:29:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LuisRuby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ea666f/32.png) [@LuisRuby](https://www.ruby-forum.com/u/LuisRuby)\
**Post date:** [July 9, 2010, 9:29pm UTC](https://www.ruby-forum.com/t/template-is-missing-but-it-is-there/191342/1 "2010-07-09T21:29:37Z")

</div>

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](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!!

---

<div class="post-metadata">

**Author:** ![LuisRuby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ea666f/32.png) [@LuisRuby](https://www.ruby-forum.com/u/LuisRuby)\
**Post date:** [July 10, 2010, 12:45am UTC](https://www.ruby-forum.com/t/template-is-missing-but-it-is-there/191342/2 "2010-07-10T00:45:43Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![LuisRuby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ea666f/32.png) [@LuisRuby](https://www.ruby-forum.com/u/LuisRuby)\
**Post date:** [July 9, 2010, 9:53pm UTC](https://www.ruby-forum.com/t/template-is-missing-but-it-is-there/191342/3 "2010-07-09T21:53:02Z")

</div>

On 9 July 2010 18:24, LuisRuby [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> @instit = Instit.find(:all, :order =\> ‘created\_at asc’)
> 
> \<% end %\> Nome
> 
> [http://localhost:3000/serv\_instit/shownames?instit\_id=3](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
