Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Is there any way to let uses repost an existing post?

In my projects I would like uses to repost existing posts. Is there any way you can do it and how do you do it?

1 Answer

Try this out.

We know that in a repost everything is the same except for the poster (author) and possibly the timestamps on when it was posted (or reposted).

How about we create a new post object, copying over all the details of the original post and simply submit it as the current user or as the re-poster. This will create a new timestamp for the new object (the repost) while maintaining all the same attributes as the original post except the submitter.