Попытка просмотреть атрибут ссылочного документа. Проблема в индексном файле задачи. Когда я пытаюсь отобразить тег, связанный с задачей, я получаю следующую ошибку:
BSON::InvalidObjectId in Tasks#index
Ошибка находится в строке '‹%= task.tag.title %>' в файле index.html.erb.
пользователь.rb
class User
include Mongoid::Document
field :name
validates_presence_of :name
validates_uniqueness_of :name, :email, :case_sensitive => false
attr_accessible :name, :email, :password, :password_confirmation
embeds_many :tags
embeds_many :tasks
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
тег.rb
class Tag
include Mongoid::Document
field :title
embedded_in :user, :inverse_of => :tags
references_many :tasks
end
задача.rb
class Tag
include Mongoid::Document
field :title
embedded_in :user, :inverse_of => :tags
references_many :tasks
end
index.html.erb
<% @tasks.each do |task| %>
<tr>
<td><%= task.name %></td>
<td><%= task.tag.title %></td>
</tr>
<% end %>
Спасибо,