Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to skip json_escape for strings? #472

Open
ExReanimator opened this issue Jul 1, 2013 · 1 comment
Open

How to skip json_escape for strings? #472

ExReanimator opened this issue Jul 1, 2013 · 1 comment

Comments

@ExReanimator
Copy link

Controller:

def create
    @status = 0
    @errors = Array.new

    if @user.save
      @status = 1
    else
      @user.errors.full_messages.each { |e| @errors << e }
    end
end

View (create.json.rabl):

object false

node(:status) {|m| @status }

if @errors.any?

  child @errors => :errors do
    extends "error"
  end

end

partial "_error":

object @errors

node(:text) { |e| e }

Result

=> "{"status":0,"errors":[{"error":{"text":"\xD0\x9F\xD0\xB0\xD1\x80\xD0\xBE\xD0\xBB\xD1\x8C \xD0\xBD\xD0\xB5 \xD0\xBC\xD0\xBE\xD0\xB6\xD0\xB5\xD1\x82 \xD0\xB1\xD1\x8B\xD1\x82\xD1\x8C \xD0\xBF\xD1\x83\xD1\x81\xD1\x82\xD1\x8B\xD0\xBC"}},{"error":{"text":"\xD0\x9F\xD0\xBE\xD0\xB4\xD1\x82\xD0\xB2\xD0\xB5\xD1\x80\xD0\xB6\xD0\xB4\xD0\xB5\xD0\xBD\xD0\xB8\xD0\xB5 \xD0\xBF\xD0\xB0\xD1\x80\xD0\xBE\xD0\xBB\xD1\x8F \xD0\xBD\xD0\xB5 \xD0\xBC\xD0\xBE\xD0\xB6\xD0\xB5\xD1\x82 \xD0\xB1\xD1\x8B\xD1\x82\xD1\x8C \xD0\xBF\xD1\x83\xD1\x81\xD1\x82\xD1\x8B\xD0\xBC"}}]}"

The problem is that in another rabl templates of my project strings was not decoded to utf symbols. How to disable that?

@awinogradov
Copy link

+1
I have this problem too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants