Changed controller code blocks to ruby format