Skip to content

Instantly share code, notes, and snippets.

Created January 3, 2013 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4446901 to your computer and use it in GitHub Desktop.
Save anonymous/4446901 to your computer and use it in GitHub Desktop.
@dealer = Dealer.find_or_create_by_name("Surugaya")
@dealer.transaction do
@article = dealer.articles.create(:title => "Test")
@unit = article.units.create(:price => 300)
end
@Yoshiji
Copy link

Yoshiji commented Jan 3, 2013

dealer = Deal.find_or_create_by_name('Surugaya')
article = Article.create(title: 'test')
unit.create(article_id: article.id, dealer_id: dealer.id, price: 300)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment