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