Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associations: use class association path instead of association name #425

Open
nicolas-besnard opened this issue Dec 26, 2016 · 6 comments

Comments

@nicolas-besnard
Copy link

In the following case:

class RemoteBankAccount
  collection_path 'bankaccounts'
end
class RemoteUser
  has_many :bank_accounts
end

I could be nice to use collection_path instead of the association name.

If you are ok, I can do the PR :)

@edtjones
Copy link
Collaborator

edtjones commented Dec 26, 2016 via email

@nicolas-besnard
Copy link
Author

nicolas-besnard commented Dec 26, 2016

When I specify the class, it doesn't use the collection_path (or resource_path) defined on the associated class.

As you can see on the here, the association name is used to find the path

@edtjones
Copy link
Collaborator

Hi @nicolas-besnard OK I understand. Makes sense to parameterise that I guess. A PR would be welcome :)

@nicolas-besnard
Copy link
Author

I think changing this will break people code. We should use an options for this.

What do you thing ? Should it be the default behavior ?

@edtjones
Copy link
Collaborator

I think it should be parameterised / optional @nicolas-besnard . You want to take a swing at a PR and we'll see how we go? Thanks loads for being involved :-)

@zacharywelch
Copy link
Collaborator

zacharywelch commented Aug 15, 2018

+1 on using collection_path as a default for has_many. Association paths in general could use some ❤️ to get them in sync with Relation

In the meantime here's a workaround:

class RemoteBankAccount
  collection_path 'bankaccounts'
end

class RemoteUser
  has_many :bank_accounts, path: "/bankaccounts"
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants