Solved

Tidy Ruby on Rails Code

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
If-Then-Else ASP problem 6 60
Does video get better conversion rates? 2 47
Wrapper for APPs 9 76
Chrome: Need to display Favorites' URL icons in the task bar 4 38
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

776 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