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

schema without an ID #98

Closed
jwoertink opened this issue Jun 19, 2017 · 2 comments · Fixed by #100
Closed

schema without an ID #98

jwoertink opened this issue Jun 19, 2017 · 2 comments · Fixed by #100

Comments

@jwoertink
Copy link
Contributor

I didn't see this as an option in the code, or in the docs.

Some tables might not have an ID or any sort of primary key because they could be used as join tables. It would be nice to have an option to specify (or have it documented if this exists)

schema "cars" do
  has_many :car_owners, CarOwner
  has_many :owners, Owner, through: :car_owners
end

# maybe something like this?
schema "car_owners", id: false do
  updated_at_field nil
  created_at_field nil
  belongs_to :car, Car
  belongs_to :owner, Owner
end

schema "owners" do
   has_many :car_owners, CarOwner
   has_many :cars, Car, through: :car_owners
end
@fridgerator
Copy link
Member

Definitely a useful option.

You MIGHT be able to get away with throwing primary_key: true on another field in that model as a temporary solution? Right now its used for loading and deleting associations, but if you're doing this manually it might work.

@jwoertink
Copy link
Contributor Author

Cool. I'll try that out. Thanks!

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

Successfully merging a pull request may close this issue.

2 participants