Skip to content

Commit

Permalink
fix: Creating or Updating a story without attaching media (#979)
Browse files Browse the repository at this point in the history
This fix checks for media existence before attempting to loop and attach
media.

Co-authored-by: Laura Mosher <lauramosher@users.noreply.github.com>
  • Loading branch information
lauramosher and lauramosher committed Oct 27, 2023
1 parent 17ae2db commit 4ac38c3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rails/app/controllers/dashboard/stories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def create
@story = community_stories.new(story_params.except(:media))

if @story.save
story_params[:media].each do |media|
story_params[:media]&.each do |media|
m = @story.media.create(media: media)
end
redirect_to @story
Expand All @@ -45,7 +45,7 @@ def update
@story = authorize community_stories.find(params[:id])

if @story.update(story_params.except(:media))
story_params[:media].each do |media|
story_params[:media]&.each do |media|
m = @story.media.create(media: media)
end

Expand Down

0 comments on commit 4ac38c3

Please sign in to comment.