n00b 问题。我正在尝试遍历数据库中的每个用户记录。伪代码可能看起来像这样:
def send_notifications
render :nothing => true
# Randomly select Message record from DB
@message = Message.offset(rand(Message.count)).first
random_message = @message.content
@user = User.all.entries.each do
@user = User.find(:id)
number_to_text = ""
@user.number = number_to_text #number is a User's phone number
puts @user.number
end
end
有人可以告诉我这样做的最佳方法吗?对语法的一点帮助也会很棒:)