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 %> |
<%= 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!!