Skip to main content

Subscribe to GoRails to get access to this episode and all other pro episodes, and new awesome content every month.

Subscribe Now
Only $19/month

Unlimited access. Cancel anytime.

25 Common Features:

Repost / Retweet / Reblog

Episode 118 · May 10, 2016

Learn how to add the common "Retweet" or "Reblog" functionality in your Rails app with self-referential associations

Sharing


Transcripts

Subscribe or login to view the transcript for this episode.

Discussion


Fallback

Thanks Chris! Sure, would love to see the follow and following relationship added to this in future.


Fallback

Thanks Chris!! Would love to see the follow and following relationship added to this in the future too


Fallback

Hi Chris, Great tutorial! I was wondering how to setup liking posts when I don't have any user records. Assuming I want to setup it for my blog and for sure I'm going to be the only user so how could I implement it?!


Fallback
This was just what I needed, man. I tried to build out this feature myself and I ended up making it way more complicated than it should have been. I also now understand a few more things about Rails, so thanks for this. 
Fallback
Great to hear Dan! Let me know if there are any other features like this you'd like to see!

Fallback
Hey Chris, you may have forgotten one important component for this feature. The unsharing AJAX button for the second state. Currently, my repost feature breaks when I mistakenly double click and record the changes into the db. Can you provide a quick update to this solution to balance it out and then post the updated repository link? Thanks!

Fallback
Its such a unique solution that its very hard to alter without complicating the logic. Also, we should be able to get the count for the shares, and also access the users that shared the posts. Example: rebecca, john, toby, tyler shared.

Fallback

Any help on this please; how can I count the number of times the original tweet has been retweeted?

Fallback

Retweets is simply a count the number of associated tweets.

@tweet.tweets.count


Fallback

Thanks for the quick response Chris.
I have tried @tweet.tweets.count on the tweet show page but I'm getting an error " undefined method `tweets' for #Tweet:0x007ffcab0608d8
Did you mean? tweet
tweet= "

This is showing in the console

=> #<ActiveRecord::Relation [#<Tweet id: 1, user_id: 1, body: "First tweet", tweet_id: nil, created_at: "2018-09-06 04:14:56", updated_at: "2018-09-06 04:14:56">, #<Tweet id: 2, user_id: 2, body: "second tweet", tweet_id: nil, created_at: "2018-09-06 04:16:58", updated_at: "2018-09-06 04:16:58">, #<Tweet id: 3, user_id: 2, body: nil, tweet_id: 1, created_at: "2018-09-06 04:25:34", updated_at: "2018-09-06 04:25:34">, #<Tweet id: 4, user_id: 1, body: nil, tweet_id: 2, created_at: "2018-09-06 04:54:44", updated_at: "2018-09-06 04:54:44">, #<Tweet id: 5, user_id: 1, body: nil, tweet_id: 2, created_at: "2018-09-09 12:09:01", updated_at: "2018-09-09 12:09:01">

Apart from this, everything else work fine for me in this tutorial.


Login or create an account to join the conversation.