1- George cannot be added to the blog because a particular blog belongs to a user
One way is to define two type of associations referencing the User
model from the Blog
, something like:
class Blog < ActiveRecord::Base
has_one :owner, class_name: "user", foreign_key: :owner_id
has_many :users
end
This way many users may belong to a blog while it has only one owner.
2- How am I suppose to know who wrote what post for what blog
Your current setup does support doing:
@user.posts.includes(:blog)
#should give you all posts for user George along with blog details for each post
3- How to build an Optimal design?? (my opinion)
I learned (the hard way) that making the optimal solution when it comes to design won't work by trying to make it perfect from the beginning !! Start experimenting with what you came up with and by making small changes, you will gradually reach your optimal solution.
What i want to say is, "Don't Over-Think It", because you will never figure what's wrong till you play with it.