我想在我的索引中使用ajax进行脚手架的'显示'动作,但是当我点击show时,我的文件没有出现任何内容:
finances_controller.rb
def show
@finance = Finance.find(params[:id])
end
_show.html.erb
<p id="notice"><%= notice %></p>
<p>
<b>Date update:</b>
<%= @finance.updated_at %>
</p>
<p>
<b>Money:</b>
<%= @finance.money %>
</p>
<p>
<b>Entrance:</b>
<%= @finance.entrance %>
</p>
<p>
<b>Description:</b>
<%= @finance.description %>
</p>
<p>
<b>Situation:</b>
<%= @finance.situation %>
</p>
<p>
<b>Local:</b>
<%= @finance.local %>
</p>
<%= link_to 'Edit', edit_finance_path(@finance) %> |
<%= link_to 'Back', finances_path %>
我 index.html.erb修改了按钮show:
Bem vindo <%= session[:user_name]%>
<div id='list' align='left'>
<h1>Finanças - Hoje é dia <%= Date.today %></h1>
<%= link_to 'New Finance', new_finance_path %>
<table cellpadding="5" >
<tr>
<th>Data de Inserção</th>
<th>Caixa</th>
<th>Entrada</th>
<th>Descrição</th>
<th>Situação</th>
<th>Local</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @finances.each do |finance| %>
<tr>
<td><%= finance.created_at %></td>
<td><%= finance.money %></td>
<td><%= finance.entrance %></td>
<td><%= finance.description %></td>
<td><%= finance.situation %></td>
<td><%= finance.local %></td>
<td><%= link_to 'Show', finance,:action => 'show',:id => @finance , :remote =>:true %></td>
<td><%= link_to 'Edit', edit_finance_path(finance) %></td>
<td><%= link_to 'Destroy', finance, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
<br />
</div>
<div id='tools' align='right'>
<%if @finance %>
<%= render('show') %>
<% end %>
</div>
<%= link_to 'Logout', new_session_url,method: :delete %>
当我在节目中点击时出现网址'localhost:3000 / finances / 1'但是当我点击这个我想要点击并在同一页面中显示我的部分'节目'时,我不会发生任何事情,我渲染部分'节目'如果指定了@finance,
<%if @finance %>
<%= render('show') %>
<% end %>
答案 0 :(得分:0)
尝试使用= render 'finances/show'