ruby-trello icon indicating copy to clipboard operation
ruby-trello copied to clipboard

API endopoints paths must not depend on ActiveSupport pluralization as it breaks with other languages

Open vizcay opened this issue 6 years ago • 0 comments

I've added ruby-trello on a Rails v4.2 project (had used it without problems in others projects without rails).

To my surprise when I started trying to query anything 404 errors began:

pry(main)> Trello::Organization.find('xxx')
E, [2019-05-01T13:01:11.722604 #74796] ERROR -- : [404 GET https://api.trello.com/1/organizationes/xxx]: Cannot GET /1/organizationes/sistemasvizcay?key=xxx&token=xxx
Trello::Error: Cannot GET /1/organizationes/xxx?key=xxx&token=xxx
from /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/ruby-trello-2.1.0/lib/trello/client.rb:99:in `invoke_verb'

What quickly got my attention was Cannot GET /1/**organizationes**/. Clearly something was odd and after digging at the code I've found this:

    def find(path, id, params = {})
      response = get("/#{path.to_s.pluralize}/#{id}", params)
      trello_class = class_from_path(path)
      trello_class.parse response do |data|
        data.client = self
      end
    end

Clearly the path is being pluralized via ActiveSupport.. but, what If my Rails project has spanish language inflections as is the case? This is brittle and a bad idea as it only works with the english inflections rules. Worst, It looks I cannot configure it some other way than monkey patching.

Any chance this will be fixed?

vizcay avatar May 01 '19 16:05 vizcay