I get this error
undefined method `created_at’ for #ActiveRecord::Relation:0x0000001c3f57e8
controller
@user = User.find_by_username(params[:username])
@post = @user.comment_threads
if @post
last_time = @post.created_at
if Time.now - last_time <= 0.5.minute
redirect_to messages_received_path
flash[:notice] = "You cannot spam!"
return
end
end
Because this line
@post = @user.comment_threadsreturns an object ofActiveRecord::Relationto you. Better put a.lastor.firston the end of that sentence, so you can have a singlePostobject.