0
나는 프로그램을 실행했고 모든 것이 잘 작동한다. 지금 일부 테스트를 작성하려고하는데이 오류가 계속 발생합니다.레일즈 3의 인코딩 오류
Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8
제 지식에 이상한 문자가 없습니다. 나는이 오류로 어디에서 시작해야할지 모른다. 나는이 두 줄을 environment.rb 파일에 추가하려고 시도했다.
Encoding.default_internal = Encoding::UTF_8
Encoding.default_external = Encoding::UTF_8
그리고 도움이되지 않았다. 다음 시험은 내가 실행하려고하고 있습니다 : 여기
require 'test_helper'
class UserTest < ActiveSupport::TestCase
test "should require all fields" do
u = User.new
assert_false u.valid?
end
end
내 users.yml 파일입니다
Creating sqlite :memory: database
-- create_table("comment_votes", {:force=>true})
-> 0.0021s
-- create_table("comments", {:force=>true})
-> 0.0013s
-- add_index("comments", ["post_id"], {:name=>"index_comments_on_post_id"})
-> 0.0005s
-- create_table("posts", {:force=>true})
-> 0.0015s
-- create_table("users", {:force=>true})
-> 0.0013s
-- create_table("votes", {:force=>true})
-> 0.0010s
-- initialize_schema_migrations_table()
-> 0.0009s
-- assume_migrated_upto_version(20111005200722, ["db/migrate"])
-> 0.0013s
Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8
1 테스트, 0 주장 : 여기
one:
name: MyString
password: MyString
two:
name: MyString
password: MyString
<% (1..5).each do |i| %>
user_<%= i %>:
name: user_<%= i %>
password: user_<%= i %>
<% end %>
내 스택 추적한다 , 0 실패, 1 오류, 0 보류, 0 누락, 0 알림
테스트 스위트 완료 : 0.058747 초
종료 코드 1로 처리가 완료된 프로세스
예, 비밀번호가 암호화됩니다. 코드를 어디에 넣었습니까? – user972276
글쎄, 필자는 ActiveRecord가 아닌 DataMapper를 사용했기 때문에 필자의 경우 실제로는 DM에있는 버그 (https://github.com/datamapper/dm-core/pull/141)에 대한 버그였습니다. 어쩌면'password_salt ='(또는 그 필드가 무엇이든간에)'password_salt'를 정의하고 거기서 할 수 있을까요? – d11wtq
비밀번호 팅팅 및 로직 확인을 게시 할 수 있습니까? 나는 아마 그 이상을 도울 수있다. 즉, 유효한 UTF-8이기 때문에, 데프 self.salt = self.object_id.to_s + 내가 암호 – d11wtq