Problems with Rubygem and Task
AnsweredHi, I've run into a couple of problems regarding the Task element.
Problem 1. Get Task.
When I try Podio::Task.find(task_id) Rails raises an error related to mass-assignment for a handful of the attributes. I'm not trying to assign any values, just fetch the details. The only solution I can think of is to make the attributes accessible in the gem's model file, Task.rb , but that's not really a good solution.
Problem 2.
When multiple tasks are fetched it appears like the API sends the wrong "created_by" details. For a task I've created my colleague (also an admin) appears to be the creator. Even though it was created by, assigned to and completed by me.
My setup is this: rubygem, oauth2 and Rails version 3.2.3.
Other than that it's a great API.
-
Hi Jakob,
Podio::Task.find and Podio::Task.find_all works fine for me. We use them inside the Podio web app, and I just retested them in the console to make sure. Also, the get to problem 2, I guess you must have overcome problem 1? If that's not the case, please supply the specific call you are making (exactly which options are you supplying?) and the exact error and stack trace you are getting. Feel free to replace any sensitive information with X's or something.
As for created_by, I'm pretty sure that works just like it should. If you see "Created by [name] N days ago" on podio.com/tasks and you are looking at the same task from the API, you will see the same created_by information, as it is the same code that is getting executing. If you are still sure you are getting the wrong created_by, please supply the call you are making, the id of the task(s) with the wrong created_by, which created_by id you get and which you expect to get. You can also doublecheck what you get out using the sandbox API access: https://developers.podio.com/doc/tasks/get-task-22413
-
Hi Casper
Thanks for that. Now everything is working just fine: I replaced Podio::Task.find() with Podio.connection.get('task/task_id'). The reason the former of the two didn't work is probably that the action where it is called is a POST-requested action.
Regarding Podio::Task.find_all() the created_by_id referred to the space, I've just realized.
Thanks for your help.
-
Hi Jakob,
All the former does is to make the latter call inside the method and deserialize it from a hash into a Ruby object. So the only reason the latter would work for you, but not the former, is if the deserialization goes wrong.
I'd still like to see you code and the error (with stacktrace) you get when using Podio::Task.find(), as I'd like to get the client fixed if there is a problem.
-
Sure. No problem. I've set up a simple test to reproduce the problem.
Various code: http://cl.ly/text/0e1x2j1Z2H17
Working code responds in html: #Faraday::Response:0x0000012f22a300
Failing code responds: http://cl.ly/image/1h0z1S1t3l05
Full trace: http://cl.ly/text/0K3b0y1L3V3X -
Okay, I've found and fixed the problem. Turns out the Podio client was assuming that the ActiveRecord class called User I assume you have in your app, was in fact an ActivePodio class. I've added a check, so it falls back to the Podio class and doesn't class with ActiveRecord models with the same name. You'll need to update your Podio gem to version 0.8.0.
I've also updated our Rails sample project to prove that looking up a task now actually works, even with an ActiveRecord object named user: https://github.com/podio/podio_rails_sample
Thanks a lot for your help with identifying this problem.
Please sign in to leave a comment.
Comments
7 comments