I have in model post.rb:
class Post
include Mongoid::Document
attr_accessible :content, :original_post
end
in create action in posts_controller.rb:
def create
@post = Post.new(params[:post])
@post.original_post = @post
@post.save
end
I want to know that this post is the original because I will do copy of this post and I will have more post with the same features.
However when I try create the post, I get the error:
BSON::InvalidDocument (Cannot serialize an object of class Post into BSON.):
Have you tried to serialize empty Post, like:
May be the problem is that
@postcontains itself as variable. And it cannot be serialized to json (bson).