Michael Hartl rails tutorial twitter @replies feature extension

105 views
Skip to first unread message

dasibre

unread,
Jun 14, 2013, 9:23:32 AM6/14/13
to rubyonra...@googlegroups.com
Hi,
I completed the Michael Hartl tutorial, and i'm trying to add the twitter like @replies feature to the app but I'm completely lost. Here is what I have so far.

I added the in_reply_to column to the Micropost Model and created a User, has_many through microposts relationship. I'm lost after that. Any assistance will be greatly appreciated.

User Model

 has_many :microposts, dependent: :destroy
 has_many :replies, through: :microposts, source: :in_reply_to
Micropost Model
 class Micropost < ActiveRecord::Base
  attr_accessible :content
  belongs_to :user
  belongs_to :in_reply_to, class_name: "User"

Matt Jones

unread,
Jun 15, 2013, 4:10:52 PM6/15/13
to rubyonra...@googlegroups.com
Here's a hint: how should in_reply_to get a value? Perhaps you could set it based on scanning the text of the micropost about to be created?

--Matt Jones 

dasibre

unread,
Jun 15, 2013, 10:37:18 PM6/15/13
to rubyonra...@googlegroups.com
Thanks for the hint, i think thats one of the things i couldn't figure out. It was a trial and error to get this far.  
Reply all
Reply to author
Forward
0 new messages