Skip to content

Instantly share code, notes, and snippets.

@y00rb
Created July 7, 2014 09:16
Show Gist options
  • Save y00rb/809b75b81905f8a8c8ee to your computer and use it in GitHub Desktop.
Save y00rb/809b75b81905f8a8c8ee to your computer and use it in GitHub Desktop.
how to organize getting fat models.
# app/models/invoice.rb
class Invoice < ActiveRecord::Base
has_many :items
end
# app/models/invoice.rb
class Item < ActiveRecord::Base
belongs_to :invoice
end
# app/models/invoice/item.rb
###################################
## refactor Item as follow
###################################
class Invoice::Item < ActiveRecord::Base
belongs_to :invoice
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment