victor-am / rails-ranger

🤠 An opinionated AJAX client for Ruby on Rails APIs
https://victor-am.github.io/rails-ranger/
MIT License
32 stars 5 forks source link

Get method doesn't use existing resource #28

Closed ryanmk54 closed 5 years ago

ryanmk54 commented 5 years ago

I have the route current_sbm_employees_path | GET | /merchandising/sbm_employees/current(.:format) I tried to access it with api.resource('sbm_employees').get('current') but that gives me /merchandising/current It works correctly if I use api.resource('sbm_employees').list('current')

Based on the documentation it appears that accessing the url with the get method should work too.

victor-am commented 5 years ago

Hey @ryanmk54 sorry for the delay (I got sick over the weekend 🤒) This is indeed a problem, gonna work on this later this week 👍

But I guess it all started because you have a singular resource in current which isn't yet supported and being so using the list function seemed weird.

I guess this is one more reason to figure out some way to work with singular resources 🤔

victor-am commented 5 years ago

Sorry about the delay, it should be fixed on #30 Can you check if this solves your problem?

I will probably be merging it and releasing a new version next week 👍

ryanmk54 commented 5 years ago

I don't think it fixed it. I still get the same url as before.

victor-am commented 5 years ago

Weird 🤔 Gonna check it out later. Just to be sure though: did you use the version of the code inside the #30 pull request? 🤔

ryanmk54 commented 5 years ago

I changed

package.json to

"rails-ranger": "victor-am/rails-ranger#vam-move-raw-requests-to-route-builder",

which resulted in the following yarn.lock entry after yarn install

rails-ranger@victor-am/rails-ranger#vam-move-raw-requests-to-route-builder:
  version "1.1.2"
  resolved "https://codeload.github.com/victor-am/rails-ranger/tar.gz/ec6f9f0dc09dbc3cd06b4e64e0395a49da88105b"
  dependencies:
    axios "^0.18.0"
    humps "^2.0.1"
    lodash "^4.17.10"
    qs "^6.5.0"

Using api.resource('sbm_employees').get('current') results in /merchandising/current

victor-am commented 5 years ago

So I investigated and my bad, I forgot to warn that just pointing to my PR would still load the old version because my PR didn't re-build the dist files 🤦‍♂

But I did the test with a personal project and seems to be working fine with the new code 😄

So I just published v1.1.3, try upgrading the library in your app and the problem should be fixed 🎉

ryanmk54 commented 5 years ago

Awesome! Thanks. It worked.