3 ms·
May slightly OT: The best naming scheme for page name I've ever seen is to use body#controller.action then put CSS relevant to a single controller in Rails-gene
by sirn 14y ago
May slightly OT: The best naming scheme for page name I've ever seen is to use body#controller.action then put CSS relevant to a single controller in Rails-generated controller_name.css.scss. It helps preventing crashing while keeping file count to minimum. Extra bonus, it also provide ability to reuse certain CSS within same controller. For example:
# articles.css.scss
body#articles {
/* We display title in LARGE RED TEXT in articles controller. */
h2 {
font-size: 24px;
color: red;
}
&.index {
/* Oh noes we don't really want LARGE RED TEXT here. */
h2 { font-size: 16px; }
}
}
All my projects now started this way. It's very maintainable.
- ruckusing 14y agoI love this method and have almost the exact setup. I do the same for JS too. In the footer of every page: $(document).ready(function() { if (V.Views.orders_index) { V.Views.orders_index(); } } Where "V.Views.orders_index" is basically "${controller}_${index}". Thus you just need to actually define that function in an included JS and voila, thats your calling hook and your JS is invoked.