Skip to content

Instantly share code, notes, and snippets.

@smathy
Last active September 30, 2015 16:37
Show Gist options
  • Save smathy/9e950624bc149aeec8e9 to your computer and use it in GitHub Desktop.
Save smathy/9e950624bc149aeec8e9 to your computer and use it in GitHub Desktop.
class Project < ActiveRecord::Base
has_many :tasks
end
[10] pry(main)> t = Task.new
=> #<Task:0x007ffd9073ecf0 id: nil, project_id: nil, created_at: nil, updated_at: nil>
[11] pry(main)> p = t.build_project
=> #<Project:0x007ffd895e2598 id: nil, created_at: nil, updated_at: nil>
[12] pry(main)> p.tasks
=> []
class Task < ActiveRecord::Base
belongs_to :project
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment