1

I'm very new to rails.

I have an existing MS SQL DB and build the rails-app on it. I just scaffolded all required stuff from the existing tables.

But, I have an Umlaut in my index.html.erb source code.

<td><%= wohnung.Grösse %></td>

But this raises an 500 Internal Server Error.

The development.log doesn't helps me...:

Started GET "/wohnungs" for 127.0.0.1 at 2012-01-05 13:52:24 +0100
Processing by WohnungsController#index as HTML
[1m[36mWohnung Load (0.0ms)[0m  [1mEXEC sp_executesql N'SELECT [Wohnung].* FROM [Wohnung]'[0m
Rendered wohnungs/index.html.erb within layouts/application (15.6ms)
Completed 500 Internal Server Error in 62ms

If I remove this line, it works. But every other umlaut in texts is represented by a '�' ...

What I did:

  • Added '#coding: utf-8' on top of the wohnung_controller
  • Added 'encoding: utf8' to the database.yml,
  • Added 'config.encoding = "utf-8"' to the application.rb,
  • Added meta http-equiv="Content-Type" content="text/html; charset=utf-8" to the application.html.erb-file.

I've no idea what I could do next...Please help :)

Greetings, Beasty

2
  • Not sure if its a typo but, '#coding: utf-8' on top of the wohnung_controller must read '#encoding: utf-8' Commented Jan 5, 2012 at 13:19
  • Yep, it was an typo... The error occurs in the the *.html.erb files actually. But I added meta-tags for the unicode etc. But nothing changes, I still got the problem... Commented Jan 5, 2012 at 16:08

1 Answer 1

1

Why don't you use a less problematic circumscription like wohnung.groesse ? You probably only have to rename a database column. It is not recommendable to use special characters in a function or database column name.

Sign up to request clarification or add additional context in comments.

6 Comments

Yeah it's generally a bad idea to put non-ASCII characters in method names, it only generates problems (like this one).
Yes you're right. I'll rename them, Thanks :-) But I've still the problem, that the umlauts in my text aren't displayed correctly. The umlauts are represented by an �-icon. (Those strings from the db-entry in the webpage...) How to solve that? :/
utf8 is the right encoding. If the database has the charset utf8 it should work. You can select the encoding in the database.yml and in the rails migration create_table through the option 'DEFAULT CHARSET=utf8'
Hi. It looks like the db has the encoding 'latin 1'...Could this be the reason for the misbehaviour with the umlauts?
yes, of course. You can change the default character set for a MySQL database or table with ALTER DATABASE or ALTER TABLE, see also here: woss.name/2006/10/25/…
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.