Q:

Pulley system. Why do I need to put a minus sign?

I am a mathematics undergraduate who's struggling to understand elementary physics. The following exercise looks particularly obscure to me.
A $3.70\,\text{kg}$ mass (let's call it $m_1$) is connected to a $2.30\,\text{kg}$ mass (let it be $m_2$) through a massless and inextensible rope, which is bent by a pulley like in the figure below.

I need to compute the acceleration of the masses ($a$) and the tension of the rope ($T$). By considering two different reference frames for each mass (as the picture shows), I worked out the following equations for the forces acting on $m_1$ along its $x$-axis, and those acting on $m_2$ along its $y$-axis:
$$
\begin{cases}
T - m_1g\sin{30^{\circ}} = m_1a \\
T - m_2g = m_2a
\end{cases}
$$
In order to come up with this system, I observed that:

$T$ must be the same at each end of the rope, because it is inextensible;
the same argument proves that the acceleration $a$ is the same for both masses;
$T$ has a positive direction in both reference frames, whereas $-m_1g\sin{30^{\circ}}$ and $-m_2g$ always have a negative one (hence the minus signs).

I thought I had done everything correctly, but when I attempted to compute $a$ and $T$ my results could not agree with those I found in my book. After a few tries, I found out that the above system would yield the right solutions, if only I change the sign of $m_2a$ like this:
$$
\begin{cases}
T - m_1g\sin{30^{\circ}} = m_1a \\
T - m_2g = \color{red}{-m_2a}
\end{cases}
$$
This apparently agrees with the fact that, from a physical point of view, $m_2$ will go downward while pulling $m_1$ toward the pulley. My question is: am I supposed to know this in advance? Do I need the knowledge of what-mass-is-pulling-the-other-one-and-where to solve the problem? I also have to mention that, because $m_1$ has a greater mass, I initially thought that $m_1$ would be the one sliding downward while lifting $m_2$ toward the pulley, so I tried to rewrite the first system with $-m_1a$ instead of $m_1a$ (leaving $m_2a$ untouched). As you can guess, that didn't help.
I just want to understand why my reasoning is flawed. I chose the signs of $T$, $-m_1g\sin{30^{\circ}}$, $-m_2g$ so that they would agree with the reference frames I used, while I had to leave $m_1a$ and $m_2a$ as they are because I did not know how the system would be going to evolve. Yet it seems this knowledge is necessary to understand the mechanics of the two masses. How is this possible?

A:

Yes, you need to know it in advance. Here's how you do so: In the first equation you wrote, $a$ is positive if the object moves higher on the slope. If this object moves higher up on the slope, the object hanging on the rope would go downwards. That means that a positive $a$ and by extension, a positive force would point downwards. So your equation should not be $T-m_2g=m_2a$ but $m_2g-T=m_2a$.

A:

$T$ has a positive direction in both reference frames

This is incorrect.  $T$ is a scalar property of the rope and has no direction.  The attachment of the rope to the masses provides a force on the mass, and this does have a direction.
The magnitude of $T$ and the applied force are the same, but the direction of the applied force needs to be accounted for in your reference.  
So a single $T$ turns into separate forces on the two masses, and these forces are in different directions along the path of travel, so they should have different signs.

A:

Better to write
$$T - m_1g\sin\theta = m_1a_1$$
$$T - m_2g = m_2a_2$$
$$ a_1 = -a_2$$
The acceleration variables represent the acceleration of each mass in its own independent coordinate system, so they should be identified as such.  The third equation is an equation of constraint that establishes the connection between the two coordinate systems.  By choosing one variable to represent the acceleration of both, you miss that connection.   
Keep the coordinate systems separate, and identify constraints explicitly.   The simpler problems do yield easily to the approach of choosing a particular set of axes chosen to make the motion appear simple.  But complicated problems with several objects connected in complicated ways you will go crazy trying to figure out the "simple" arrangement of axes that simplifies the motion while at the same time respecting the constraints.  Each object gets a coordinate system; systems are related by equations of constraint.   This is a systematic approach that will pay dividends in the long run.  It's a good habit to establish, in my opinion.

