0
我有這個問題,我必須使用has_many:through關係來查詢大量數據。此代碼SQLite中而不是在PostgreSQL的如何解決PostgreSQL中未定義的方法
我的控制器:
@task_logs_unapprove = TaskLog.includes(:client).includes(:staff).where(completed_at: nil).page(params[:page]).per_page(10).all
而我的看法:
<div class="panel panel-dark panel-light-green">
<div class="panel-heading"><span class="panel-title">Unapprove Task Logs</span>
<div class="panel-heading-controls"><%= will_paginate @task_logs_unapprove, renderer: BootstrapPagination::Rails %></div>
</div>
<table class="table table-bordered">
<thead class="cf">
<tr>
<th>Task Code</th>
<th>Client</th>
<th>Staff</th>
<th>Work Time Today</th>
<th colspan="4"></th>
</tr>
</thead>
<tbody>
<% @task_logs_unapprove.each do |task_log| %>
<tr>
<td data-title="Name"><strong><%= task_log.task_code %></strong></td>
<td data-title="Name"><strong><%= task_log.client_name %></strong></td>
<td data-title="Name"><strong><%= task_log.staff_name %></strong></td>
<td data-title="Name"><strong><%= task_log.sum_of_hrs %></strong></td>
<td data-title="Name"><strong><%= link_to 'View', task_log %></strong></td>
<td data-title="Name"><strong><%= link_to 'Edit', edit_task_log_path(task_log) %></strong></td>
<td data-title="Name"><strong><%= link_to ' Unapproved', complete_task_log_path(task_log), method: :patch %></strong></td>
<td data-title="Name"><strong><%= link_to 'Delete', task_log, method: :delete, data: { confirm: 'Are you sure?' } %></strong></td>
</tr>
<% end %>
</tbody>
</table>
</div>
注意到這一工作在SqlLite但不能在PostgreSQL的
繼承人我的日誌中的錯誤heroku:
ActionView::Template::Error (undefined method `full_name' for nil:NilClass):
<div class="panel-heading">
<span class="panel-title">Unapprove Task Logs</span>
<div class="panel-heading-controls">
<%= will_paginate @task_logs_unapprove, renderer: BootstrapPagin <div class="panel-heading"> <span class="panel-title">Approve Task Logs</span> <div class="panel-heading-controls"><%= will_paginate @task_logs_approve, renderer: BootstrapPaginat <div class="panel-heading"><span class="panel-title">Unapprove Task Logs</span><div class="panel-heading-controls"><%= will_paginate @task_logs_unapprove, renderer: BootstrapPagin <div class="panel-heading"> <span class="panel-title">Approve Task Logs</span> <div class="panel-heading-controls"><%= will_paginate @task_logs_approve, renderer: BootstrapPaginat</div>nd %>iv>ong>Sorry!</strong> You Dont Have Permission To View This Page.m_of_hrs %>
</td>
的FULL_NAME錯誤是在我人員和客戶表
這與你使用postgres無關,而是它在你的數據庫中的數據。 – BroiSatse
從代碼中很難說出問題的出在哪裏,因爲在這裏沒有一個單引用'full_name'。我的猜測是'client_name'被定義爲'client.full_name'。如果是這樣,那麼你的一個task_logs沒有被分配任何客戶端。 – BroiSatse
我在我的task_log.rb模型中定義了'client_name',就像這樣'''''''''''''''''''client client_name #{client.full_name} end''' 與staff_name –