1
我使用關係(has_many , belongs_to)
他與上面的源代碼一起工作,但我在獲取error document Not Found
以更改關係(embeds_many, embedded_in
)時刪除照片(圖片)。任何人Helpme請,如何使用mongoid &這裏有什麼錯我的源代碼使用Embed_many relations
:如何在使用Rails 4刪除和銷燬Mongoid中的嵌入式文檔
class Room
include Mongoid::Document
field :home_type, type: String
field :room_type, type: String
embeds_many :photos
end
class Photo
include Mongoid::Document
include Mongoid::Paperclip
embedded_in :room
end
class PhotosController < ApplicationController
def destroy
@photo = Photo.find(params[:id])
room = @photo.room
@photo.destroy
@photos = Photo.where(room_id: room.id)
respond_to :js
end
end