# وضع علامة على المنشورات كحلّة في المستورد

**URL:** <https://meta.discourse.org/t/mark-posts-as-solved-in-an-importer/80146>\
**Category:** Development\
**Created:** [9 فبراير 2018، 12:23ص UTC](https://meta.discourse.org/t/mark-posts-as-solved-in-an-importer/80146 "2018-02-09T00:23:07Z")\
**Posts on this page:** 1\
**Showing post:** 1

<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:** [9 فبراير 2018، 12:23ص UTC](https://meta.discourse.org/t/mark-posts-as-solved-in-an-importer/80146/1 "2018-02-09T00:23:07Z")

</div>

I’m working on an importer for answerhub and need to mark posts as solved. A couple other importers do something like this:

```ruby
            if topic["answer"] == '[accepted]'
              post.custom_fields['is_accepted_answer'] = true
            end

```

And then later call this:

```ruby
  def mark_topics_as_solved
    puts "", "Marking topics as solved..."

    PostAction.exec_sql <<-SQL
      INSERT INTO topic_custom_fields (name, value, topic_id, created_at, updated_at)
      SELECT 'accepted_answer_post_id', pcf.post_id, p.topic_id, p.created_at, p.created_at
        FROM post_custom_fields pcf
        JOIN posts p ON p.id = pcf.post_id
       WHERE pcf.name = 'is_accepted_answer'
    SQL
  end

```

When I do that, the posts don’t show up as solved, but if I try to mark a post as solved, I get a 500 error (presumably because it’s trying to mark a solved post as solved).

Is there something that I need to do to get rails to notice that the table has been updated?

My other solution is to just do this as a `post_create_action`

```ruby
            if topic["answer"] == '[accepted]'
              post.custom_fields['is_accepted_answer'] = true
              the_topic = Topic.find(parent)
              the_topic.custom_fields['accepted_answer_post_id'] = post.id
              the_topic.save
            end

```

---

_[View the full topic](https://meta.discourse.org/t/mark-posts-as-solved-in-an-importer/80146)._
