Skip to content

Commit

Permalink
bug: fix crash on new note (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
adnjoo authored Nov 2, 2024
1 parent b0c7d94 commit 40c5845
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ def new

def create
@note = current_user.notes.build(note_params)
@note.owner = current_user

if @note.save
@note.users << current_user unless @note.users.include?(current_user) # Add to collaborators
redirect_to notes_path, notice: "Note created successfully."
else
flash.now[:alert] = "Note creation failed."
render :new, status: :unprocessable_entity
render :index, status: :unprocessable_entity
end
end

Expand Down

0 comments on commit 40c5845

Please sign in to comment.