[英]Render partial scaffold in the index view - Rails
我想使用ajax在索引中显示脚手架的动作“显示”,但是当我单击显示时,我的文件没有出现:
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修改了按钮显示:
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 %>
当我在节目中单击时出现URL'localhost:3000 / finances / 1',但当我单击此按钮时却什么也没发生,我想单击并在同一页面中显示我的部分“显示”,如果指定了,我将渲染部分“显示” @finance,
<%if @finance %>
<%= render('show') %>
<% end %>
尝试使用= render 'finances/show'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.