Rails отображает пустое значение и идентификатор на мой взгляд, модель
Я вид Рельсы, который выводит содержимое значения модели в этом случае agenda.subject
Проверка дб дна две вещи не в БД, я знаю: идентификатор и заготовки являются лишь то, что в моем коде может привести к его показать, как этот
пользователей/index.html.erb
<div class="row">
<div class="span8">
<%= render 'agendas/agenda_form' %>
<% if @user.agendas.any? %>
<h2>Agendas (<%= @user.agendas.count %>)</h2>
<ol class="agendas">
<%= render @agendas %>
</ol>
<% end %>
</div>
</div>
the _agenda.html.erb partial
<li>
<span class="content"><%= agenda.subject %></span>
<%= link_to 'delete', agenda, method: :delete,
confirm: "You Sure?",
title: agenda.subject %>
</li>
и й е пользователей контроллер
class UsersController < ApplicationController
before_filter :authenticate_user!
def index
@user = current_user
@agenda = current_user.agendas.build if signed_in?
@agendas = current_user.agendas
end
end
.... user_id: 1, created_at: "2012-05-17 15:52:22", updated_at: "2012-05-17 15:52:22"> # ] 8
[#<Agenda id: 49, subject: "Ut qui vel eos quia vitae.", due_date: nil, completed: nil, user_id: 1, created_at: "2012-05-17 15:52:22", updated_at: "2012-05-17 15:52:22">, #<Agenda id: 43, subject: "Enim dolorem.", due_date: nil, completed: nil, user_id: 1, created_at: "2012-05-17 15:52:22", updated_at: "2012-05-17 15:52:22">, #<Agenda id: 37, subject: "Rerum architecto est nihil totam.", due_date: nil, completed: nil, user_id: 1, created_at: "2012-05-17 15:52:22", updated_at: "2012-05-17 15:52:22">, #<Agenda id: 31, subject: "Non.", due_date: nil, completed: nil, user_id: 1, created_at: "2012-05-17 15:52:22", updated_at: "2012-05-17 15:52:22">, #<Agenda id: 25, subject: "Libero enim et explicabo.", due_date: nil, completed: nil, user_id: 1, created_at: "2012-05-17 15:52:22", updated_at: "2012-05-17 15:52:22">, #<Agenda id: 19, subject: "Et molestiae et quia saepe quia.", due_date: nil, completed: nil, user_id: 1, created_at: "2012-05-17 15:52:22", updated_at: "2012-05-17 15:52:22">, #<Agenda id: 7, subject: "Eum consectetur iste.", due_date: nil, completed: nil, user_id: 1, created_at: "2012-05-17 15:52:22", updated_at: "2012-05-17 15:52:22">, #<Agenda id: nil, subject: nil, due_date: nil, completed: nil, user_id: 1, created_at: nil, updated_at: nil>] 8
я исключил первую пару записей, которые они выглядели нормально, но его эти последние 2, которые являются странно выходом из @ agendas.inspect и @ agendas.length
Я использую обманщик создать образец данных для приложения, возможно, преступника?
Можете ли вы напечатать, что '@ agendas.inspect' и' @ agendas.length' перед вызовом цикла? –
редактируемый вопрос с вышеуказанными запросами. – TheIrishGuy