Railguns aren't extremely effective weapon
Assumptions
I have to make some assumptions, as they aren't provided by OP. And those assumptions will cut out some possible use cases and technologies, which we may call railguns too. I have to do so to narrow the modeling and shorten the answer.
ships engines use thermonuclear power, with variable ISP. The same thermonuclear power is used to launch projectiles.
projectiles are dump chunks of metal, let's say Iron with 10GPa tensile strength, 2000 GPa Young's modulus, no maneuvers. (basically a chunk of steel 10 times stronger than usual)
speed of projectiles is arbitrary from 0.9c to 4 km/s
efficiencies are 100%, both for engines and for launching projectiles.
ships are aware of that they are in a combat situation, and they understand from which direction to expect a hit. (no invisibility in space for ships) Ships are equipped with detectors of IR signatures not worse than Spitzer with ran out of liquid helium coolant. More about what this assumption practically may mean in the answer
form of projectiles parallelepiped, proportions (1,1,3), mass 1 ton or less.
Modeling the possible situations
High-velocity projectiles.
Destruction limits for the projectiles
For a chunk of metal with tensile strength of 10GPa energy needed for destruction of 1 cubic meter of it into 0.001m size chunks is something like 10/200 * 0.001 * 1e10 * 3 * (1/0.001) = 1'500'000'000 J (it is under assumption that we exfoliate it layer by layer, 1mm thick layers in each of 3D dimensions, and we do a work which is defined by elongation before it breaks(which is determined by Young's modulus and strength of the material) until we get bunch of small 1mm cubes from it and it seems that the energy is invariant in those assumptions which seem to be correct actually)
certainly, it represents the needed energy at the order of magnitude and depends only on the volume of the projectile. For our 1 ton projectile, it will be about 7.5 times less, so for the destruction the projectile as a solid object, we need 200'000'000J or less.
Collision of projectile with a thin flat shield
Same material used as a thin flat shield against a projectile and the question is How thick it has to be to destroy the projectile and the energy of the collision.
Assume collision is an inelastic collision, the thickness of the flat shield is "d".
Energy which will be spent on heating and destruction (ignoring relativistic effects) should be
$$0.5 \cdot \frac{m_p \cdot m_s}{m_p + m_s}(0.9c - 0)^2 > 200'000'000J \qquad (1)$$
$$m_s = \rho \cdot d \cdot \left(\frac{m_p}{3\cdot\rho}\right)^{2/3}$$
$$\frac{m_p + m_s}{0.5 \cdot m_p \cdot m_s \cdot 0.81c^2} < 1/200'000'000$$
$$m_s << m_p \Rightarrow \frac{200000000}{0.5 \cdot 0.81c^2} < m_s$$
For 1 tonne projectile we need a section of shield with mass 2×10^8÷(0.5×0.81×9×10^16) = 0.000000005 kg < ms to destroy the projectile as solid object. The destruction does not protect the ship yet because those remains are more than capable of destruction of the ship itself. We need to spend more energy to disperse those remains, to reduce the amount of debris which are potentially capable of hitting the ship.
Cone of destruction
Now comes in play the distance between the ship and destroyed projectile and energy we spend on the destruction.
The same energy which destroyed the projectile has to be used to give that debris the velocity to fly off the projectile. More energy is spent in collision faster those particles will disperse and higher velocities they will have perpendicular to the original velocity vector. This motion will form some sort of cone(probably with some complex density distribution, but for simplicity I assume it is even distribution)
To for a cone with angle 1 grad, those particles have to get in average 0.007853882c radial velocity, or for our 1 tonne projectile it means that energy of collision have to be more than 2.775755811×1015J thus mass of the shield(which collides with projectile) has to be 0.076152423kg, which is much more than it was needed just to destroy the projectile(so basically material strength does not matter), but still not that much.
- Energy of collision can be greatly improved for high-velocity collisions by using thermonuclear fuel as a shield, thus requiring even less mass for the shield. This will work at about 0.1c relative velocities.
The thickness of the shield will be about
0.076152423÷7500×(3×7500÷1000)^(2÷3) = 0.000080924m $\approx$ 0.1mm
A square kilometer of it will weight 606930 kg or about 600 ton.
The distance between the shield and thus the place where the projectile will be dispersed has to be pretty distant if we would like to reduce the amount of debris which may potentially hit the ship. Let's assume an even distribution of the debris and that the ship can survive the collision with one gram of it and projection of the ship in the direction of attack is 10000 square meters, the angle of the cone is one grad.
To satisfy the requirements distance has to be
sqrt(1000000×10000÷3.14)÷tan(0.5) = 6'466'611 meters or about 6500 km
- considering the speed of the potencial projectile (0.9c) and its mass (1'000'000 gram) it is a surprisingly short distance.
0.1c velocity projectile
Destruction energy the same - 200'000'000J
Mass of section of the shield for the destruction energy has to be 0.000000444 kg (which is 88.28 times more than with 0.9c projectile)
Radial velocity for the cone has to be 0.000872654c (which 9 times less than for 0.9c, obviously)
Energy of collision has to be 3.426859026×1013 (81 times less than with 0.9c)
Mass of section of the shield has to be 0.076152423 (the same as for 0.9c case)
Distance can be 81 times less than in 0.9c, as 1 gram at 0.1c carries 81 times less energy (ignoring relativistic effects for 0.9c, which is about 2.3 times difference in kinetic energy compared to newton physics, I'm too lazy to deal with it for 2.3 times difference in results)
Shield thickness about the same 0.1mm.
So, in general, there are not that many changes compared to the situation of the 0.9c projectile, and no changes in efficiency for the same shield, but it is because the energy we should have to make the cone is orders of magnitude higher than the energy needed to destroy(make loose) the projectile.
low-velocity projectile
At some point energy needed to destroy the projectile will be close to the energy needed to form the cone and begins to play a more significant role.
For the 1-grad cone, it will be at velocities about 72 km/s , so, let's see the same for the projectile at 70 km/s
Destruction energy the same - 200'000'000J
Mass of section of the shield for the destruction energy has to be 0.081632653 kg
Radial velocity for the cone has to be 610 m/s
Energy of collision has to be 186587642 J
Mass of section of the shield has to be (for energy of collision 200'000'000J + 186'587'642J) - 0.157790874 kg
Shield thickness about as twice as much as for 0.1c and 0.9c projectiles - 0.2mm
with lower speeds, the needed thickness begins to grow as crazy, because the energy of the inelastic collision proportional to the square of relative velocity differences - so for 35 km/s projectile it will be 4 times thicker, for 7 km/s it will be 100 times thicker. Still, it is better than solid armor, and that is Whipple shield velocities. 1km/s projectiles and we are in the field of usual armor.
Efficiencies of (whipple style) shield at different speeds
0.9c - very efficient
0.1c - very efficient
70 km/s - efficient
7 km/s - kinda efficient
1 km/s - not efficient
0.99999c - it depends.
Notes about tactic in the situation.
First of all - the distance between ships is the friend in the situation, against high velocity and for low-velocity projectiles, but for different reasons. For low velocity, because of they just too slo-o-o-o-w. For high-velocity projectiles - it needs noticeable distance between countermeasures and the ship itself, for the base of destruction cone to be big enough, compared to ship projection in direction of attack.
Lasers as point defense are just inefficient, just forget about them for high-velocity projectiles they are just useless.
Unmanned drones which deploy the shield are useful things. They may deploy and keep with acceleration speed of the main ship. (there are different ways to do so, and they are technology dependant)
Great distance is good for missiles, the higher velocity at the target, especially those missiles which are with thermonuclear engines.
High-velocity projectiles will emit IR signature, no matter how efficient was their launch, just because of interstellar medium
Shield of death.
The Recent invention of space combat industry presents you a shield of death. Mobile, relatively light weight, almost tested in "Children of a Dead Earth"
A grid of guided interception missiles.
A volume which filled with interception missiles, with low delta-v, small, at distance of about 5km from each other, with some kinda weak guide system.
Or modified version of it, with tethers between nearby nodes.
Will be good for stationary bases and to protect volumes. Might be good against missiles, and low and medium velocity projectiles. 400 km (80 layers) will guarantee the safety of your gold-pressed latinum and your life.
Buy now - satisfaction guaranteed, call 666-777-42, do not wait, the enemy does not sleep, call now 666-777-42.
Conclusion
Railguns aren't extremely effective weapon by any means. Missiles are a better choice, but they aren't perfect either.
Rail guns are close combat weapon, and to allow the enemy on the distance which is effective for them, it needs to be very simple minded. Especially in space where you see the possible enemy at a.u. distances.
I haven't used all my assumptions because it would make the answer needlessly too long, but the problem is pretty rich on details, and small changes in those details may change the picture drastically.
Implementing a bit more sophisticated technologies to those projectiles may make them significantly more effective, but the same will be true for defense.
At the end better prepared will win the battle and it will be not those who have only rail guns or have them at all.
I kinda recommend the game "children of death earth" - it's not ideal in the available technologies, but it might help to choose the characteristics of weapon you may need. Definetly it's better than nothing, and at the moment there are no other easy available options for simulating the kinda stuff.