# Question Answer Plugin

**URL:** https://meta.discourse.org/t/question-answer-plugin/56032
**Category:** Plugin
**Tags:** deprecated
**Created:** [January 19, 2017, 4:43pm UTC](https://meta.discourse.org/t/question-answer-plugin/56032 "2017-01-19T16:43:47Z")
**Posts on this page:** 20
**Page:** 6

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [July 10, 2018, 11:06am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/109 "2018-07-10T11:06:47Z")

</div>

@angus A custom field would probably be the best option here. Do you store the votes somewhere?

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [July 10, 2018, 11:12am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/110 "2018-07-10T11:12:36Z")

</div>

They were being stored as vote post actions, i.e. in the `vote_count` column.

Would it be possible to delay the deletion of existing `vote_count` data? Everything else I can work around.

---

<div class="post-metadata">

### Author: ![kinto\_d](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kinto_d/32/100776_2.png) [@kinto\_d](https://meta.discourse.org/u/kinto_d)
#### Post date: [July 10, 2018, 11:14am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/111 "2018-07-10T11:14:08Z")

</div>

I’ve changed Discourse version to v2.0.2 but still have the same error.

Already checked inside the container and Post.rb model has “vote\_count” attribute.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [July 10, 2018, 11:19am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/112 "2018-07-10T11:19:06Z")

</div>

As in you’re using the PostAction model to store the votes on each post? Because if the plugin is, the votes post action would have been nuked upon upgrade. What I’m going to do instead is to ignore the vote\_count column for now and remove the migration that drops the post action.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [July 10, 2018, 11:23am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/113 "2018-07-10T11:23:29Z")

</div>

> [@tgxworld](#):
>
> As in you’re using the PostAction model to store the votes on each post?

Yes

> [@tgxworld](#):
>
> Because the plugin is the votes would have been nuked upon upgrade.

Indeed

> [@tgxworld](#):
>
> What I’m going to do instead is to ignore the vote\_count column for now and remove the migration that drops the post action.

Thanks, I’ll update the plugin to migrate any existing `vote_count`s to custom\_fields tomorrow.

After a grace period we can remove the existing `vote_count` columns.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [July 10, 2018, 11:25am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/114 "2018-07-10T11:25:49Z")

</div>

Hmm the vote count column isn’t the critical one here since you can recalculate it from the post\_actions. Unfortunately for @kinto_d, the columns have already been dropped.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [July 10, 2018, 11:29am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/115 "2018-07-10T11:29:34Z")

</div>

There’s probably a ‘history’ record somewhere I can use to reconstitute any lost data for the period the migration was active. I would check now, but I’m _sans_ laptop.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [July 10, 2018, 11:30am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/116 "2018-07-10T11:30:58Z")

</div>

Just in case, we removed the migration in

[https://github.com/discourse/discourse/commit/b49c662aa4724b4761927a7ceb31bcda35f9880a](https://github.com/discourse/discourse/commit/b49c662aa4724b4761927a7ceb31bcda35f9880a)

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [July 10, 2018, 11:31am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/117 "2018-07-10T11:31:45Z")

</div>

Much appreciated. Will handle the ‘migration’ to custom fields in this plugin asap.

---

<div class="post-metadata">

### Author: ![RCheesley](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rcheesley/32/455409_2.png) [@RCheesley](https://meta.discourse.org/u/RCheesley)
#### Post date: [July 10, 2018, 8:35pm UTC](https://meta.discourse.org/t/question-answer-plugin/56032/118 "2018-07-10T20:35:32Z")

</div>

Just to say, I had this issue having just rebuilt as part of a domain migration and had Discourse update itself (and plugins, it seems) which was causing a 500 error.

The logs were showing NoMethodError (undefined method `vote_count' for NoMethodError (undefined method `vote\_count’ for … etc.

Took some time to identify the issue as I thought initially it must be a routing error from the domain migration! That’ll teach me to remember to update plugins first! 😳

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [July 13, 2018, 3:16am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/119 "2018-07-13T03:16:13Z")

</div>

Ok, an update here. Sorry for the delay, this caught me at an inconvenient time.

I’ve just merged an update that:

- Updates the plugin to use various `custom_fields` to store vote data and integrates that into a functionality identical post vote action UX.

- Migrates existing post vote actions to the new custom\_fields.

[https://github.com/angusmcleod/discourse-question-answer/commit/257a6c680b8855790ae70b950654f91686e727a8](https://github.com/angusmcleod/discourse-question-answer/commit/257a6c680b8855790ae70b950654f91686e727a8)

Example topic: [https://discourse.angusmcleod.com.au/t/can-you-solve-aldhelms-lorica/59](https://discourse.angusmcleod.com.au/t/can-you-solve-aldhelms-lorica/59)

 ![Screenshot%20at%20Jul%2013%2011-34-49](https://global.discourse-cdn.com/meta/original/3X/4/b/4bfb64ec29e9cfcc70da7f018ea37a0293008e7b.png) ![Screenshot%20at%20Jul%2013%2013-06-10](https://global.discourse-cdn.com/meta/original/3X/0/4/04a2b95502b5d00834445a9b3a58f4bd9e183a06.png)

This should work seamlessly for anyone who did not upgrade Discourse between these commits:

- [Remove legacy vote post action code. (#6009) · discourse/discourse@96aca6d · GitHub](https://github.com/discourse/discourse/commit/96aca6d7e6dc3c05d761098a19f96b82d2783b1c) ;and

- [Remove the clean up migration for vote post action · discourse/discourse@b49c662 · GitHub](https://github.com/discourse/discourse/commit/b49c662aa4724b4761927a7ceb31bcda35f9880a)

If you did upgrade Discourse between these commits, after upgrading Discourse and this plugin the QA functionality will work fine, but all votes in existing QA topics will be ‘0’.

The best idea I’ve come up with so far to retrieve vote data for those that upgraded between those commits is to search the production logs for instances of `PostAction create`, filtering by type and reducing by `PostAction destroy` (filtered by type). If anyone else has a better idea, let me know.

Rebuilding data from server logs is something of a last ditch effort, but nonetheless if you upgraded in specified period and you’re interested in this solution, please let me know.

---

<div class="post-metadata">

### Author: ![kinto\_d](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kinto_d/32/100776_2.png) [@kinto\_d](https://meta.discourse.org/u/kinto_d)
#### Post date: [July 15, 2018, 7:41am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/120 "2018-07-15T07:41:23Z")

</div>

After I update the plugin, I can’t delete the question post (including normal post). Does this just happen to me? or does this happen to others too?

Thanks.

```
Started DELETE "/t/37" for 140.213.20.175 at 2018-07-15 07:26:14 +0000
Processing by TopicsController#destroy as */*
  Parameters: {"context"=>"/t/lounge-tesests/37", "id"=>"37"}
Clearing Active Record cache, this can happen if schema changed while site is running or in a multisite various databases are running different schemas. Consider running rake multisite:migrate.
Completed 500 Internal Server Error in 39ms (ActiveRecord: 14.6ms)
ActiveRecord::StatementInvalid (PG::UndefinedColumn: ERROR: column "vote_count" of relation "posts" does not exist
LINE 1: ...osts" SET "bookmark_count" = 0, "like_count" = 0, "vote_coun...
                                                             ^
: UPDATE "posts" SET "bookmark_count" = 0, "like_count" = 0, "vote_count" = 0 WHERE "posts"."id" = 59)
/var/www/discourse/vendor/bundle/ruby/2.5.0/gems/rack-mini-profiler-1.0.0/lib/patches/db/pg.rb:95:in `exec'
Failed to handle exception in exception app middleware : PG::UndefinedColumn: ERROR: column "vote_count" of relation "posts" does not exist

```

---

<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: [July 15, 2018, 8:22am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/121 "2018-07-15T08:22:27Z")

</div>

You might try a rebuild, especially if you upgraded from the web interface.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [July 15, 2018, 11:07pm UTC](https://meta.discourse.org/t/question-answer-plugin/56032/122 "2018-07-15T23:07:02Z")

</div>

What version of the plugin and what version of discourse are you running?

---

<div class="post-metadata">

### Author: ![Jose\_C\_Gomez](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jose_c_gomez/32/137297_2.png) [@Jose\_C\_Gomez](https://meta.discourse.org/u/Jose_C_Gomez)
#### Post date: [July 24, 2018, 1:37pm UTC](https://meta.discourse.org/t/question-answer-plugin/56032/123 "2018-07-24T13:37:09Z")

</div>

Installed this, pretty nice however it has an issue with the Badge Flairs on the “Sub replies” see below.

Discourse:  
v2.1.0.beta2 +422

 ![image](https://global.discourse-cdn.com/meta/original/3X/d/a/dab27c69c26cd5e7294991cb2f4897ef85096d6a.png)

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [July 25, 2018, 3:37am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/124 "2018-07-25T03:37:23Z")

</div>

Thanks, now fixed 🌞

> <https://github.com/paviliondev/discourse-question-answer/commit/af4290fa234929bc90db17c629ee7b6b48b7b520>

---

<div class="post-metadata">

### Author: ![sinister89](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sinister89/32/99847_2.png) [@sinister89](https://meta.discourse.org/u/sinister89)
#### Post date: [July 25, 2018, 4:53pm UTC](https://meta.discourse.org/t/question-answer-plugin/56032/125 "2018-07-25T16:53:10Z")

</div>

@angus I had the same issue. I am using version 0.2

I reported this as a issue here [500 Error when Deleting Post · Issue #9 · paviliondev/discourse-question-answer · GitHub](https://github.com/angusmcleod/discourse-question-answer/issues/9)

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [July 26, 2018, 11:59pm UTC](https://meta.discourse.org/t/question-answer-plugin/56032/126 "2018-07-26T23:59:42Z")

</div>

@sinister89 @kinto_d @barreeeiroo Thanks guys, there was indeed an issue. Should be fixed now. Please update and try again.

---

<div class="post-metadata">

### Author: ![sinister89](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sinister89/32/99847_2.png) [@sinister89](https://meta.discourse.org/u/sinister89)
#### Post date: [August 3, 2018, 5:03pm UTC](https://meta.discourse.org/t/question-answer-plugin/56032/127 "2018-08-03T17:03:40Z")

</div>

@angus is there an easy way to collapse the comments and hide them and give a button which user needs to click to show comments, like in medium?

 ![46%20PM](https://global.discourse-cdn.com/meta/original/3X/f/0/f01f46f56f415a0b7ce5beef3e89f90485f0ed73.png)

Thought behind this feature request is that if the comments are too many or too long, then distract the user from the Answers. Quora and Stackoverflow also do some kind of collapsing but that might need more work.

Stackoverlfow

 ![34%20PM](https://global.discourse-cdn.com/meta/original/3X/8/f/8f58c995a9479a9fe6a9f1d62fb78f876ccf2345.png)

Quora

 ![00%20PM](https://global.discourse-cdn.com/meta/original/3X/1/9/19ac100b8151f3009e01ef67b673f683cda9d69e.png)

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [August 5, 2018, 4:18am UTC](https://meta.discourse.org/t/question-answer-plugin/56032/128 "2018-08-05T04:18:54Z")

</div>

Yeah, that’s doable. Remind me next Friday and I’ll do it next weekend.

[Previous page](https://meta.discourse.org/t/question-answer-plugin/56032.md?page=5)

[Next page](https://meta.discourse.org/t/question-answer-plugin/56032.md?page=7)
