Are $injective$ homomorphisms required for the universal property of the fraction field? Consider the universal property for the fraction field of an integer domain:

Let $R$ be a integral domain, $F(R)$, its fraction field, $K$ some field and $f:R\rightarrow K$ a injective homomorphism, i.e. $R$ is embedded via $f$ in $K$. Then there exists a unique homomorphism $g$ such that $g\circ \varepsilon =f$, where $ \varepsilon $ is the map that embeds $R$ in $F(R)$.

Now my question is: Can we drop the requirement that $f$ is injective ? If we do that, the proof I have in mind has to be modified, since in it $g$ is defined as $g(\frac{a}{b})=f(a)f(b)^{-1}$ and  the fact that $f$ is injectiv implies that $f(b)$ is nonzero, which is necessary for $f(b)$ to be invertible.
Although I couldn't come up with a new proof where I define my $g$ in a different way, I also couldn't come p with a counterexample, i.e. some $R,K$ and $f$ such that for every homomorphisms $g$ we have $ g\circ \varepsilon \neq f$. And looking through the internet and books makes me think that the "injectiveness" of $f$ is necessary.
EDIT Since I didn't put enough thought to this, as the first comment shows, I'm modifying my question to consider $g$ only as a ring homomorphism.
 A: Several people have already answered your question to show that injectivity is necessary in the universal property of the fraction field. However, there is a more general construction which works when the map is not injective, namely localization.
If $f: R \to K$ is a ring homomorphism, with $R$ a domain and $K$ a field, then let $P = f^{-1}(0)$ be the kernel of the map. Note that $P$ is necessarily prime, as $R/P \hookrightarrow K$. Then the localization of $R$ at $P$ is the ring $R_P$ with all elements not contained in $P$ inverted. In fact, it's the subset of $\mathrm{Frac}(R)$ where the denominators can be any element not in $P$. Hence $R \subseteq R_P \subseteq \mathrm{Frac}(R)$. Moreover, $R_P$ is exactly characterized by this fact! Just like the fraction field it has a universal property, namely that if every element not contained in a prime ideal $P$ becomes invertible in the image, then the map factors uniquely through $R_P$.
For a concrete example, let $R = \mathbf{Q}[x,y],$ and $K = \mathbf{Q}(x)$. Since any map from $R$ is uniquely determined by where it maps $x$ and $y$, we define $f: R \to K$ to be the map given by $x \mapsto x$, $y \mapsto 0$. It is not hard to see that the kernel of this map is exactly the prime ideal $(y) \subset R$, so $f$ factors uniquely through $R_{(y)}$. The elements of $R_{(y)}$ are exactly fractions of $R$ with denominators not divisible by $y$, so $\frac{x^2y}{x^2+y^2-1} \in R_{(y)}$ but $\frac{3}{xy+y^2}$ is not.
In the special case that the map is injective, then $P = (0)$. Since every nonzero element of $R$ lies outside of $P$, then every element is inverted and we see that $R_{(0)} = \mathrm{Frac}(R)$.
A: No, we cannot. For example, take $R=\mathbb{Z}$, $K=\mathbb{Z}/2\mathbb{Z}$, and $f$ to be the canonical map. Since $f(2)=0$, there's no way to define $f(1/2)$, and so $f$ cannot be extended to $\mathbb{Q}$.
A: First observe that the kernel of any ring homomorphism is always an ideal,
regardless of whether you require ring homomorphism to map $1$ to $1$ or not
(I should add that it is standard to require this when one deals exclusively
with rings with $1$). So for a ring homomomorphism $g: F(R) \to K$
between fields, its kernel will either be $0$ (in which case $g$ is injective)
or $F(R)$ (in which case $g$ is the constant zero-map). Consequently, the
composition $g\circ\varepsilon$ will either be injective or zero.
Therefore, if a ring homomorphism $f: R\to K$ is neither injective nor
constant it cannot possibly factor as $f = g\circ \varepsilon$.
Take for instance the map $\mathbb{Z}\to\mathbb{Z}/2\mathbb{Z}$.
