Has_many Question

trying to added user accounts to a blog i have the user accounts
created just want to associate it with blog

GabrielG1976 wrote:

trying to added user accounts to a blog i have the user accounts
created just want to associate it with blog

so a user owns a blog?

you need to add a migration to add a :user_id column to Blog.

now;

class Blog < ActiveRecord::Base
belongs_to :user
end

class User < ActiveRecord::Base
has_many :blogs
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs