I found one solution that stores the reposted data within a content
field on the model, but of course that's not a good approach. If I can
use only the object's ID, I think that would slim down the amount of
data being used. The old method is below, maybe you have a better
solution with AJAX.

Post model
has_many: reposts, class_name: "Post", foreign_key: "repost_id",
dependent: :destroy;

def repost
    orig_post=Micropost.find(params[:id]);
    if(orig_post)
      Micropost.create(user_id:current_user.id,
        content: orig_post.content,
        repost_id:orig_post.id);
      respond_to do |format|
        format.js
      end
    end
  end

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/35e3c1d54c6e2580526c5894bc7be440%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to