简体   繁体   English

在索引视图中渲染部分支架-Rails

[英]Render partial scaffold in the index view - Rails

I want exibe the action 'Show' of scaffold in my index using ajax but when i click in show dont appear nothing my files is: 我想使用ajax在索引中显示脚手架的动作“显示”,但是当我单击显示时,我的文件没有出现:

finances_controller.rb finances_controller.rb

  def show
    @finance = Finance.find(params[:id])

  end

_show.html.erb _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 %>

my index.html.erb modified the button show: 我的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 %>

when i click in the show appear the url 'localhost:3000/finances/1' but dont happening nothing when i click this i want click and show my partial 'show' in the same page, i render the partial 'show' if especified the @finance , 当我在节目中单击时出现URL'localhost:3000 / finances / 1',但当我单击此按钮时却什么也没发生,我想单击并在同一页面中显示我的部分“显示”,如果指定了,我将渲染部分“显示” @finance,

   <%if @finance %>
        <%= render('show') %>
    <% end %>

尝试使用= render 'finances/show'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM