{"action":"created","issue":{"url":"https://api.github.com/repos/loomio/loomio/issues/2120","labels_url":"https://api.github.com/repos/loomio/loomio/issues/2120/labels{/name}","comments_url":"https://api.github.com/repos/loomio/loomio/issues/2120/comments","events_url":"https://api.github.com/repos/loomio/loomio/issues/2120/events","html_url":"https://github.com/loomio/loomio/issues/2120","id":69984495,"number":2120,"title":"Updating the outcome of a proposal after it is closed","user":{"login":"niceking","id":4241125,"avatar_url":"https://avatars.githubusercontent.com/u/4241125?v=3","gravatar_id":"","url":"https://api.github.com/users/niceking","html_url":"https://github.com/niceking","followers_url":"https://api.github.com/users/niceking/followers","following_url":"https://api.github.com/users/niceking/following{/other_user}","gists_url":"https://api.github.com/users/niceking/gists{/gist_id}","starred_url":"https://api.github.com/users/niceking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/niceking/subscriptions","organizations_url":"https://api.github.com/users/niceking/orgs","repos_url":"https://api.github.com/users/niceking/repos","events_url":"https://api.github.com/users/niceking/events{/privacy}","received_events_url":"https://api.github.com/users/niceking/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/loomio/loomio/labels/Please%20help","name":"Please help","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-22T00:17:56Z","updated_at":"2015-05-19T21:40:16Z","closed_at":null,"body":"1. After a proposal had closed and I had published an outcome, a month later I tried to change the outcome of the proposal i made \r\n2. Page refreshed, got a flash message about the outcome being updated, however I scrolled down and the outcome was now empty\r\n3. Repasted in my text and tried to publish the outcome again, I *think* i got a slightly different success message saying that the outcome has been published. This time text was persisted\r\n4. Did this email everyone who responded? Unclear to me \r\n5. Have not tried to replicate in case it emails everyone each time\r\n\r\nAttached is a screenshot showing that the outcome was updated, and the republished. Also a link to the loomio for those with access to this group \r\n\r\nhttps://www.loomio.org/d/zL4cBXu1/rails-girls-at-enspiral-space?proposal=8dGKF3iO\r\n\r\n![screen shot 2015-04-22 at 12 13 46 pm](https://cloud.githubusercontent.com/assets/4241125/7265147/55ead446-e8e9-11e4-87bf-8a7ada866084.png)"},"comment":{"url":"https://api.github.com/repos/loomio/loomio/issues/comments/103675183","html_url":"https://github.com/loomio/loomio/issues/2120#issuecomment-103675183","issue_url":"https://api.github.com/repos/loomio/loomio/issues/2120","id":103675183,"user":{"login":"zacharystenger","id":7537243,"avatar_url":"https://avatars.githubusercontent.com/u/7537243?v=3","gravatar_id":"","url":"https://api.github.com/users/zacharystenger","html_url":"https://github.com/zacharystenger","followers_url":"https://api.github.com/users/zacharystenger/followers","following_url":"https://api.github.com/users/zacharystenger/following{/other_user}","gists_url":"https://api.github.com/users/zacharystenger/gists{/gist_id}","starred_url":"https://api.github.com/users/zacharystenger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zacharystenger/subscriptions","organizations_url":"https://api.github.com/users/zacharystenger/orgs","repos_url":"https://api.github.com/users/zacharystenger/repos","events_url":"https://api.github.com/users/zacharystenger/events{/privacy}","received_events_url":"https://api.github.com/users/zacharystenger/received_events","type":"User","site_admin":false},"created_at":"2015-05-19T21:40:16Z","updated_at":"2015-05-19T21:40:16Z","body":"I was able to replicate and fix this bug on my development environment.  \r\nIn the MotionsController, the update_outcome method makes this call \r\n```ruby\r\nif MotionService.update_outcome(motion: @motion, params: params, actor: current_user) \r\n```\r\nwhich passes params that look something like this (scroll to middle to see motion & outcome objects):\r\n```ruby\r\n{\"utf8\"=>\"✓\", \"_method\"=>\"patch\", \"authenticity_token\"=>\"XvDLKFeyGSBoYn+FYMeiL2oXinKUndQYJIUmaegZq0pBrng5TjkXXmom+NeN2ftvow0JUhVydxBvffaXL1B/pg==\", \"motion\"=>{\"outcome\"=>\"updated outcome goes here\"}, \"commit\"=>\"Publish outcome\", \"controller\"=>\"motions\", \"action\"=>\"update_outcome\", \"id\"=>\"fTcLrP4k\"}\r\n```\r\nThe problem is the outcome object is inside the motion object so I changed this to pass permitted_params.motion instead like it does in the create_outcome method\r\n```ruby\r\nif MotionService.update_outcome(motion: @motion, params: permitted_params.motion, actor: current_user)\r\n```\r\nwhich passes params that look something like this:\r\n```ruby\r\n{\"outcome\"=>\"updated outcome goes here\"}\r\n```\r\nAnd it worked (as far as I can tell, but I'm new to Loomio...)  \r\n\r\nAnother possible fix would be to change the MotionService update_outcome instead. Currently it does this:\r\n```ruby\r\nmotion.outcome = params[:outcome]\r\n```\r\nBut this sets the outcome to nil because params doesn't immediately have an outcome object, it is within the motion object.  To fix it change that line to this:  \r\n```ruby\r\nmotion.outcome = params[:motion][:outcome]\r\n```\r\nI have also confirmed that this solution works but I believe my other solution is better since it keeps the structure of create_outcome and update_outcome more similar and no longer passes unnecessary params.\r\n\r\nI would like to submit a PR for my first solution (changing params to permitted_params.motion) but wanted some feedback first.  \r\nThanks\r\n"}}