I am building a Project app and I need to automatically generate 1 Participant on creation of a Project record.
My model
class Project < ActiveRecord::Base
has_many :participants, dependent: :destroy, inverse_of: :project
after_create :build_a_role
private
def build_a_role
self.participant.create!(user_id: current_user.id, level: 1, participant_cat: @role.id, added_by: current_user.id)
end
end
When I try this I get this error:
undefined method `participant' for #<Project:0x007fb402707250>