Rails - How to avoid messy conditions in my views
I'm still fairly new to rails and trying to learn its 'best practices'. I've noticed when I'm drawing up my views to display a report, my views are starting to look cluttered with if-else-then conditions. If there are some good way开发者_Go百科s to avoid such mess, please advise.
General advice would be to make sure that any domain logic exists in your models, rather than the view.
Also, extract mark-up into partials if your views are getting too long.
You might also want to look at the MVVM pattern: http://en.wikipedia.org/wiki/Model_View_ViewModel
精彩评论