It’s a standard *nix patch file. The patch command could read it (see
its man page for more details), but the a/ and b/ file naming scheme
means that you’d probably be better off using git apply.
Robert K. (or others), If you do have have the exact line for the
enforce coding and in witch erb files to put it I would be happy.
To replicate this error, call:
rails -v
Rails 3.0.3
ruby - v
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]
Mysql version: 5.1.45-community-log
rails new r4_test -d mysql && cd r4_test
rails g scaffold post title:string content:string rem:text
rake db:create
rake db:migrate
rails s http://localhost:3000/posts
call ‘New Post’
to all three fields insert e.g. “löwe” or “tomáš”
After this I’ll get:
incompatible character encodings: UTF-8 and ASCII-8BIT
Extracted source (around line #15):
12:
13:
14: Rem:
15: <%= @post.rem %>
16:
17:
18:
A monkey work-around
line 18 in “app\views\posts\index.html.erb” change:
<%= post.rem.force_encoding(‘utf-8’) %>
A better work-around
1)add among the initializers:
class ActiveRecord::Base
def force_utf
attributes.each {|key, value| value.force_encoding(‘utf-8’) if
value.encoding != ‘utf-8’ if value.kind_of?(String) }
end
end
2)before first loading or using of an activerecord object in the
template
(here it is a Post) call .force_utf
here:
insert line 14 in “app\views\posts\index.html.erb”
<% post.force_utf %>
Changing InnoDb format of a table to Myisam does not help.
It is true, this problem does not appear with sqlite; but I have some
reasons to use MySQL.
I wonder, MySQL should be the couse of the problem - I have used the
same database type and revision and structure under 2.2.2 rails / 1.8
ruby without problems
I hope, next revision of ROR (3.0.4?) or mysql2 driver will solve this
problem.
It’s a standard *nix patch file. The patch command could read it (see
its man page for more details), but the a/ and b/ file naming scheme
means that you’d probably be better off using git apply.
Is possible to use a Patch command also under Windows? What about Git
under Win? Is it safe to install such patch also for ROR-beginners?
Can I modify the source files manually (to exactly know, what have I
changed)?
I’m also waiting for a fix in 3.0.4. As you asked: Does anyone know if
patch and Git exists in windows? If no; how to apply std nix patch
files?
Git exists in Windows. A *nix-style patch command probably does too,
but why are you torturing yourself with Windows?
About mysql og not. It’s religion, you know I’ve used Oracle on
Unix/Linux through many years. I like mysql, though.
SQLite (which Robert mentioned as his alternative) isn’t suitable for
production.
I no longer trust MySQL, though, and I don’t see why others still do –
it’s got too many silly weaknesses and stupidities. Given the choice,
I’ll choose PostgreSQL every time. Not religion, just being tripped up
one too many times by MySQL’s issues.
Marnen Laibow-Koser wrote in post #965696:
Git exists in Windows.
Yes, but I don’t know to work with it and therefore I cannot imagine,
how to update the core of rails without not to break it ):
but why are you torturing yourself with Windows?
Well, most of my job I make on MS Excel tables with VBA support. Now I
am trying to move to Rails, but it does not work yet… Maybe in some
months I will be not more dependent on Bill’s products (:
I’ll choose PostgreSQL every time. Not religion, just being tripped up
one too many times by MySQL’s issues.
It is not first time I hear someone prefers the postgresql…
A good comparison is on http://www.wikivs.com/wiki/MySQL_vs_PostgreSQL.
I decided to install a postgresql gem in my Rails to check it, but I
failed with:
“Installing pg (0.10.0) with native extensions
D:/Programs/ruby192/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue
in block in build_extensions’: ERROR: Failed to build gem native
extension. (Gem::Installer::ExtensionBuildError)
D:/Programs/ruby192/bin/ruby.exe extconf.rb
checking for pg_config… no
checking for libpq-fe.h… *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more”
(The same error after I ran either “gem install pg” or “bundle install”)
Marnen Laibow-Koser wrote in post #965696:
Git exists in Windows.
Yes, but I don’t know to work with it
Learn.
and therefore I cannot imagine,
how to update the core of rails without not to break it ):
I note that you conveniently neglected to quote my point that a
*nix-style patch tool also probably exists for Windows. That or Git
will apply a patchfile very nicely indeed.
but why are you torturing yourself with Windows?
Well, most of my job I make on MS Excel tables with VBA support. Now I
am trying to move to Rails, but it does not work yet… Maybe in some
months I will be not more dependent on Bill’s products (:
Start now! Use a *nix VM for Rails development. I understand Virtual
Rails is nice.
[…]
This is to much complicated for me to solve.
Well, stop complicating things further by using Windows!