A more moderate solution is to allow conflicting ideologies to exist as long as they don't reach extremes. This is usually done through mass surveillance, which supposedly should be able to catch extremists before they act. Sadly, we're still very far from Minority Report's level of accuracy.
Alternatively, we could adopt a more reactive approach which would focus on reducing the gravity of such events rather than trying to prevent them. Namely, law abiding citizens should be able to conceal-carry weapons. Although it couldn't stop all kinds of terrorist attacks, it could very well put a stop to most mass shootings. This assumes an important "good" to "bad" people ratio (where "good" is defined by the majority and/or by the state).
Basically, live in a society that's xenophobic and armed.