ActiveRecord: Reference same table twice

user_comments.rb

class UserComment < ActiveRecord::Base
belongs_to :user
belongs_to :creator, :class_name =>“User”, :foreign_key =>“poster_user_id”
end

Then reference user.user_comment.creator.login
.

See the api for ‘belongs_to’ for more on this.

you are probably going to want to add

class User < ActiveRecord::Base
  has_many :user_comments
  # add the line below
  has_many :posted_comments, :class_name => "UserComment",
:foreign_key => :posted_user_id
end

so that you can get to the comments that were posted by a particular user.