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

Add associations #6

Open
nesquena opened this issue Feb 1, 2012 · 2 comments
Open

Add associations #6

nesquena opened this issue Feb 1, 2012 · 2 comments
Assignees

Comments

@nesquena
Copy link
Collaborator

nesquena commented Feb 1, 2012

We should add association support:

class Post < YamlRecord::Base
   belongs_to :episode
   # auto-adds `property :episode_id, Integer`
end

This adds a episode_id integer foreign key reference. You can then do stuff like:

p = Post.new
p.episode = Episode.find(5)
p.save
p.episode # => <Episode id=5>
p.episode_id # => 5

or:

p = Post.new
p.episode_id = 5
p.save
p.episode # => <Episode id=5>
p.episode_id # => 5

Also adds embeds_many support:

class Post < YamlRecord::Base
  embeds_many :users
  # adds property :user_ids, Array, Integer
end

and allows for:

p = Post.new
p.user_ids = "1,2,3"
p.save
p.users # => [<User 1>, <User 2>, <User 3>]
@ghost ghost assigned nicotaing Feb 1, 2012
@robertomiranda
Copy link

💛

@nesquena
Copy link
Collaborator Author

@robertomiranda Appreciate any help with this. Code base is pretty simple. Nico and I have unfortunately somewhat abandoned this project (I still use it though).

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