From: Mike Glaz Date: 2012-07-16T11:19:34+09:00 Subject: What does this code do? I'm reading through a tutorial and found a solution for it (because I'm stuck), but I don't understand some code, so I was hoping someone could shed some light on it: USERNAME_REGEX = /@\w+/i class Micropost < ActiveRecord::Base def people_replied users = [] self.content.clone.gsub!( USERNAME_REGEX ).each do |username| user = User.find_by_username(username[1..-1]) users << user if user end users end end This is a blog/twitter like app and I'm guessing self.content should contain a string like '@mike hi how are you?'. What would be the result in the users array with such a string? The class User looks like so: class User < ActiveRecord::Base attr_accessor :password attr_accessible :name, :email, :password, :password_confirmation, :username has_many :microposts, :dependent => :destroy end -- Posted via http://www.ruby-forum.com/.