Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Add magic encoding comment to generated files

#4924

Real easy to make this one happen.

  • Boot a new Rails 3b4 app on 1.9.2
  • Make a static controller
  • in static#index, print out a helper function
  • make the helper method spit out "»"
  • Load the page and wait for the excitement

A nicer person would just attach the app to this ticket, so I did.

I'm looking to whip up a test case or a patch, but I'm a little over my head, maybe a better-equipped person can help out while I keep digging.

I just want to be accepted, that's all...

Reported by fakingfantastic · June 21st, 2010 @ 06:55 PM

State: invalid
Milestone: none
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: Low

Activity

  1. Aaron Patterson
    Aaron Patterson
    • Assigned user set to Aaron Patterson

    June 22nd, 2010 @ 05:00 PM

  2. Bruno Michel
    Bruno Michel
    • Importance changed from to Low

    You can add a comment in app/helpers/application_helper.rb to make it works:

    # encoding: utf-8
    

    It says to ruby-1.9.2 that strings in this particular file should be considered as encoded in 'utf-8' (and not 'ascii', the default value).

    June 29th, 2010 @ 10:21 PM

  3. Aditya Sanghi
    Aditya Sanghi

    I recently saw a patch that would automatically put the encoding in some generated files in Ruby > 1.9. Do you think a patch would be good to extend this in other files generated by Rails, such as the layout, application_helper.rb etc?

    @fakingfantastic, I too confirm that adding the line as @bruno suggests solves the problem.

    October 7th, 2010 @ 05:54 PM

  4. Aditya Sanghi
    Aditya Sanghi

    @fakingfantastic one more thing, i actually bothered to open your zip file and have a look just now. You cant just put » in your helper WITHOUT quotes.

    That's just wrong, no? I mean » is not a variable or a method, if you want it treated like a string you need to quote it.

    October 7th, 2010 @ 05:58 PM

  5. David Trasbo
    David Trasbo
    • State changed from new to invalid

    Aditya is right. In order to make this work you do need the quotes and setting the encoding at the top of the file. As long as you don't specify the encoding, though, quotes or no quotes, the error will always be there.

    Marking this invalid.

    October 7th, 2010 @ 08:36 PM

  6. Jeff Kreeftmeijer
  7. Jeff Kreeftmeijer
  8. Jeff Kreeftmeijer
  9. bingbing
  10. bingbing