Solved

Tidy Ruby on Rails Code

Posted on 2010-09-08
2
791 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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show MP4 file and close (HTA) 3 42
Application.cfm not found issue 2 64
CSS - Centering an image 2 47
PHP Web Development 6 68
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to dynamically set the form action using jQuery.
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…

734 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