You don't need to specify the project_id, this is done for you by using the create_project method that was provided by the association. Just run the create without the project_id and it should work.
You could do it like this but its not necessary.
def create_project_from_name new_project = create_project(:name => new_project_name) unless new_project_name.blank? self.project_id = new_project.id end
Unless you were going to check for the new projects existance first like this.
def create_project_from_name if project = Project.find(:first, :conditions => {:name => new_project_name}) then self.project_id = project.id else create_project(:name => new_project_name) unless new_project_name.blank? end end
Hi Matthew
From another perspective, perhaps you may want to look at
activescaffold
Try writing your add method like this.
def add @note = Note.new(params[:note]) @note.user_id = session[:perm] @note.save end