Solved

Tidy Ruby on Rails Code

Posted on 2010-09-08
2
790 Views
Last Modified: 2013-11-13
I have recently gotten some really messy and hard to read code from my ruby developer..
looks like this:
<%- unless current_user %>
  <div id="login-dialog" class="columns clearfix" >
    <div id="login-dialog-left" class="col-5">
      <div class="login-message">

bascially just some ruby and html together

 what can I use to automatically put in tabs and spaces etc..?
0
Comment
Question by:hubfub
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
JESii earned 250 total points
ID: 33626038
First off, I would say that this is pretty standard ERB (embedded ruby code) that is used in Rails to dynamically lay out a page, depending on the value of variables such as "current_user". There will be quite a bit of that in a Rails application.

For tabs, I assume that you mean automatic indentation depending on the structure...right? In that case you can open the code in your favorite IDE and have it do the job. I use Rubymine (http://www.jetbrains.com/ruby/index.html) myself, but there's also Aptana (http://aptana.com/) and NetBeans (http://netbeans.org/) or even TextMate (http://macromates.com/) if you're on a Mac. Depending on your experience, the vim editor (http://www.vim.org) also has automatic indentation using the '=' command and the :cindent option.

For spaces, I'm not sure what you mean. The code snippet you show is correctly formatted. If you're thinking of adding spaces surrounding the "=" in 'id="login-dialog"' I would not recommend that: there are generally no spaces between an attribute name ('id'), the equal sign, and the attribute value ('login-dialog'). Take a look at the W3C HTML tutorial (for example http://www.w3schools.com/html/html_attributes.asp) to see what I mean.
0
 
LVL 10

Assisted Solution

by:Andrew Doades
Andrew Doades earned 250 total points
ID: 33642384
Netbeans is certainly my favourite!
I will always recommend Netbeans to any ruby/ ruby on rails developer.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question