JC: added @erb_code and if loop in views. Other changes.