0

我想使用 ajax 在我的索引中显示脚手架的操作“显示”,但是当我点击显示时,我的文件没有出现:

财务控制器.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 %>
4

1 回答 1

0

尝试使用= render 'finances/show'

于 2012-08-19T19:07:39.427 回答