I'm facing the following error message:
ExecJS::ProgramError in Restaurantes#index Showing C:/rubyProject/vota_prato/app/views/layouts/application.html.erb where >line #6 raised:
TypeError: O objeto não dá suporte para a propriedade ou método Rails.root: C:/rubyProject/vota_prato
Application Trace | Framework Trace | Full Trace app/views/layouts/application.html.erb:6:in >`_app_views_layouts_application_html_erb__971963449_62998908' Request
I fixed it removing the line:
true %>
from my app/views/layouts/application.html.erb file
after I did it, I faced the other problem =(. I created a action destroy at one controller:
class RestaurantesController < ApplicationController
def destroy
@restaurante = Restaurante.find(params[:id])
@restaurante.destroy
redirect_to(action: "index")
end
def index
@restaurantes = Restaurante.all
end
def show
@restaurante = Restaurante.find(params[:id])
end
end
and my index.html.rb file:
<h1>Listagem de Restaurantes</h1>
<table>
<tr>
<th>ID</th>
<th>Nome</th>
<th>Endereço</th>
<th>Especialidade</th>
</tr>
<% @restaurantes.each do |restaurante| %>
<tr>
<td><%= restaurante.id %></td>
<td><%= restaurante.nome %></td>
<td><%= restaurante.endereco %></td>
<td><%= restaurante.especialidade %></td>
<td><%= link_to 'Mostrar', action: 'show', id: restaurante %></td>
<td>--</td>
<td><%= link_to 'Deletar', {action: 'destroy', id: restaurante},{method: "delete"} %></td>
</tr>
<% end %>
</table>
when clicked at Deletar link, it executed same action as Show action, I don't know why
Aucun commentaire:
Enregistrer un commentaire