Skip to content

Instantly share code, notes, and snippets.

@AndrewRayCode
Created February 13, 2017 01:46
Show Gist options
  • Save AndrewRayCode/a3af844913b7e786180510e062a599af to your computer and use it in GitHub Desktop.
Save AndrewRayCode/a3af844913b7e786180510e062a599af to your computer and use it in GitHub Desktop.
# PATCH/PUT /microposts/1
# PATCH/PUT /microposts/1.json
def update
respond_to do |format|
if @micropost.update(micropost_params)
format.html { redirect_to @micropost, notice: 'Micropost was successfully updated.' }
format.json { render :show, status: :ok, location: @micropost }
else
format.html { render :edit }
format.json { render json: @micropost.errors, status: :unprocessable_entity }
end
end
end
test "should update micropost" do
patch micropost_url(@micropost), params: { micropost: { content: @micropost.content, user_id: @micropost.user_id } }
assert_redirected_to micropost_url(@micropost)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment