Marco De Rossi said almost 3 years ago on Like Relationships and Global ID :

link_to  "Unfollow",post_like_path(post, id: post.to_sgid(expires_in: 1.hour)),method: :delete
Error referencing Posts::LikesController#destroy
PG::ForeignKeyViolation: ERROR: update or delete on table "posts" violates foreign key constraint "fk_rails_fbe88b52fa" on table "users_posts"
DETAIL: Key (id)=(10) is still referenced from table "users_posts".

def destroy    
  post = Post.friendly.find(params[:post_id])
  user_post = GlobalID::Locator.locate_signed(params[:id])
  user_post.destroy!    
  redirect_to post_path(post), alert: "unfollow"  
end