Updating old Polls

Continuing the discussion from Discourse 2.4.0.beta8 Release Notes:

Fantastic to see pie charts! I guess it’s not possible to retro-actively change a Poll to pie chart format e.g. by sneakily inserting chartType=pie into the inserted text? (I couldn’t get it to respond to that change, even on Post Rebake). I was attempting to update some old Polls that would benefit from that presentation. Thanks!

3 Likes

You need to do it on the rails console:

p = Poll.last
p.chart_type = 'pie'
p.save
9 Likes

Just to add to the Solution:

In my case my site usually has the poll in the first post of the Topic, so a quick way of getting to it on the rails console is this:

myPost = Topic.find_by(id: number-from-topic-url).posts.first.id
myPoll = Poll.find_by(post_id: myPost)

or if you really want to go crazy on one line (scroll right!):

myPoll = Poll.find_by(post_id: Topic.find_by(id: number-from-topic-url).posts.first.id)

Then in this case, of course:

myPoll.chart_type = 'pie'
myPoll.save
3 Likes

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