# 주제에서 첫 번째 게시물에 대한 답변의 ID를 얻는 방법?

**URL:** https://meta.discourse.org/t/how-to-obtain-the-id-of-the-reply-to-the-first-post-in-a-topic/306187
**Category:** Support
**Created:** [4월 30, 2024, 4:55오후 UTC](https://meta.discourse.org/t/how-to-obtain-the-id-of-the-reply-to-the-first-post-in-a-topic/306187 "2024-04-30T16:55:58Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![omppatil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omppatil/32/359876_2.png) [@omppatil](https://meta.discourse.org/u/omppatil)
#### Post date: [4월 30, 2024, 4:55오후 UTC](https://meta.discourse.org/t/how-to-obtain-the-id-of-the-reply-to-the-first-post-in-a-topic/306187/1 "2024-04-30T16:55:58Z")

</div>

안녕하세요!  
문제를 하나 발견했는데, 이게 실제로 오류인지 아닌지 잘 모르겠습니다. user1이 새로운 주제를 만들고, user2가 해당 주제의 첫 번째 게시글에 답글을 달면 'reply\_to\_post\_number = nil’과 'reply\_to\_user\_id = nil’이 표시됩니다. 다른 사용자가 그 주제의 게시글에 답글을 달아도 여전히 'reply\_to\_post\_number = nil’과 'reply\_to\_user\_id = nil’이 표시됩니다. 왜 이런 현상이 발생하는 걸까요? 'reply\_to\_post\_number’와 ‘reply\_to\_user\_id’ 값을 가져오는 방법이 있을까요? 도움을 주시면 감사하겠습니다.

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [4월 30, 2024, 5:10오후 UTC](https://meta.discourse.org/t/how-to-obtain-the-id-of-the-reply-to-the-first-post-in-a-topic/306187/2 "2024-04-30T17:10:29Z")

</div>

OP에 대한 답변 (아래 버튼 중 하나 사용)

> ![image](https://global.discourse-cdn.com/meta/original/4X/a/b/7/ab79b237d0df1544284cd8fd461b121a4061da19.png)

이것들은 토픽 답변이며 해당 값들을 가지지 않습니다. 값이 nil인 경우 `Topic#first_post`를 통해 OP에 접근할 수 있습니다.

예시:

```plaintext
Post.find(1507683) # 이 포스트
Post.find(1507683).topic # 이 토픽 => id=306187
Post.find(1507683).topic.first_post # 이 토픽의 OP => id=1507671
Post.find(1507683).topic.first_post.user # 토픽 작성자 => id=139851

```

---

<div class="post-metadata">

### Author: ![omppatil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omppatil/32/359876_2.png) [@omppatil](https://meta.discourse.org/u/omppatil)
#### Post date: [4월 30, 2024, 6:14오후 UTC](https://meta.discourse.org/t/how-to-obtain-the-id-of-the-reply-to-the-first-post-in-a-topic/306187/3 "2024-04-30T18:14:54Z")

</div>

답변해 주셔서 감사합니다. 해당 주제의 첫 번째 게시글을 가져오는데 성공했습니다. 사실, 저는 그 주제의 첫 번째 게시글에 달린 답변의 ID가 필요합니다.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [4월 30, 2024, 7:49오후 UTC](https://meta.discourse.org/t/how-to-obtain-the-id-of-the-reply-to-the-first-post-in-a-topic/306187/4 "2024-04-30T19:49:42Z")

</div>

나는 그게

```plaintext
Post.where(topic_id: 306187, reply_to_post_number: nil).where("post_number>1")

```

이라고 생각합니다.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [5월 30, 2024, 7:50오후 UTC](https://meta.discourse.org/t/how-to-obtain-the-id-of-the-reply-to-the-first-post-in-a-topic/306187/5 "2024-05-30T19:50:29Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
