Tab Problem in rails .rhtml files

Published on Author Akhil Bansal5 Comments

The situation was: running Ruby 1.8.4, Rails 1.1.2, on WinXP & WEBrick server.

My application was working fine, but as I installed Rmagick my application crashed.
I got strange errors like:

compile error /script/../config/../app/views/layouts/application.rhtml:18: parse error, unexpected $, expecting kEND

if I refresh again the error actually changes(further refreshes flip back & forth between errors):

compile error

/script/../config/../app/views/layouts/application.rhtml:18: Invalid char `01′ in expression

./script/../config/../app/views/layouts/application.rhtml:19: parse error, unexpected tCONSTANT, expecting kEND

./script/../config/../app/views/layouts/application.rhtml:20: parse error, unexpected tCONSTANT, expecting kEND

./script/../config/../app/views/layouts/application.rhtml:21: Invalid char `06′ in expression

./script/../config/../app/views/layouts/application.rhtml:21: parse error, unexpected $, expecting kEND

Then my colleagues told me the root of this problem, this was because of tabs in .rhtml files. Also they told me the simple solution:

Put template = template.gsub(/\t/, ” “) in your

\vendor\rails\actionpack\lib\action_view\base.rb file at line 496 as very first line of def compile_template
Restart webserver and you are done….

5 Responses to Tab Problem in rails .rhtml files

  1. I have similar problem in generators, but i put
    ERB.new(file.read.gsub(/\t/, ” “), nil, ‘-‘).result(b)

    in line 277 of file \ruby\lib\ruby\gems\1.8\gems\rails-1.1.6\lib\rails_generator\commands.rb

  2. This problem with rmagick should be solved by the latest version. Tabs should not be a problem for rails. The download, I believe, for the RMagick version with the fix is now up on RubyForge. Take care.

Leave a Reply

Your email address will not be published. Required fields are marked *