我面臨以下錯誤信息軌道:application.html.erb其中線#6提出:類型錯誤:紅寶石上
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
我固定它除去線:從
true %>
我的應用程序/ views/layouts/application.html.erb文件
我做到了,我遇到了另一個問題=(。我在一個控制器上創建了一個動作破壞:
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
和我index.html.rb文件:
<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>
當Deletar鏈接點擊後,執行相同的動作顯示操作,我不知道爲什麼
呀會的NodeJS做的工作也很高興它爲你的作品! – polarcare