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

undefined method `html_safe' #68

Closed
mitfik opened this issue Jun 24, 2012 · 18 comments
Closed

undefined method `html_safe' #68

mitfik opened this issue Jun 24, 2012 · 18 comments
Assignees

Comments

@mitfik
Copy link

mitfik commented Jun 24, 2012

Hi,

After upgrade r18n from 0.4.14 to 1.0.0 I've got this error:

undefined method `html_safe' for "<span style=\"color: red\">[":String

I use r18n with sinatra

gem list:

sinatra (1.3.2)
sinatra-r18n (1.0.0,)
@ai
Copy link
Member

ai commented Jun 24, 2012

Rails SafeBuffer support issue :-). I will fix it, when return to home, after few hours and release 1.0.1.

@ghost ghost assigned ai Jun 24, 2012
@ai
Copy link
Member

ai commented Jun 24, 2012

Can you show my full error trace? I need to understand, where is is localed.

@ai
Copy link
Member

ai commented Jun 24, 2012

Try to fix tests in 4d8e829, but didn’t find tyhis issue. All usage of html_safe have check for respond_to? or defined? ActiveSupport::SafeBuffer (second check may be wrong, but I didn’t understand how).

So, I need full error trace and another libraries from Gemfile (maybe SafeBuffer is loaded, but did’t included to String?).

@mitfik
Copy link
Author

mitfik commented Jun 24, 2012

     NoMethodError:
     undefined method `html_safe' for "<span style=\"color: red\">[":String
     # ./lib/casserver/views/login.erb:7:in `evaluate_source'

in login.erb:7 I have:

7         <%= t.label.central_login_title %>

To reproduce this bug You can clone rubycas-server (https://github.com/rubycas/rubycas-server) and run rspec
I will try this fix which You prepare and give You know if this help.
If You need more info just give me know.

@ai
Copy link
Member

ai commented Jun 24, 2012

Can you try latest commit from git 182ad07 to fix this issue?

Just add:

gem `r18n-core`, :git => 'git://github.com/ai/r18n.git'

And run bundle update.

@mitfik
Copy link
Author

mitfik commented Jun 24, 2012

it seems that latest commit solve this issue but I've got other problems the content is somehow damage.
I try figure out what is wrong and I will give You know.

@ai
Copy link
Member

ai commented Jun 24, 2012

Can you show me screenshotor any example?

@mitfik
Copy link
Author

mitfik commented Jun 24, 2012

I compare output and for example:

with 1.0.0

<title>RSPEC-TEST<span style="color: red">[label.central_login_title]</span>
</title>

with 0.4.14

<title>RSPEC-TESTCentralna Usługa Uwierzytelniania</title>

@ai
Copy link
Member

ai commented Jun 24, 2012

Can you show me R18n.get.locale.code output near this label?

Also, can I run you application without install in system to reproduce this error?

@mitfik
Copy link
Author

mitfik commented Jun 24, 2012

R18n.get.locale.code on both is pl

To reproduce just do:
git clone https://github.com/rubycas/rubycas-server
add gem 'r18n-core', :git => 'git://github.com/ai/r18n.git' to Gamefile
bundle exec rake

@ai
Copy link
Member

ai commented Jun 24, 2012

OK, try to repeat tomorrow.

@mitfik
Copy link
Author

mitfik commented Jun 25, 2012

give me know when You will upload something to repo because as I checked right now there is no any changes yet.
Thanks.

@ai
Copy link
Member

ai commented Jun 25, 2012

OK, I find problem place. There are some strange magic with modules, Sinatra and loading order, so sinatra-r18n take wrong :translations setting from your app.

Fix is very easy, just replace:

set :translations, File.dirname(__FILE__) + "/../../locales"

to:

R18n.default_places { File.dirname(__FILE__) + "/../../locales" }

to use global R18n places method, instead of method from Sinatra plugin.

@ai ai closed this as completed Jun 25, 2012
@ai
Copy link
Member

ai commented Jun 25, 2012

Fix README.md and prefer R18n global settings for SInatra plugin: 5b24dd2

@ai
Copy link
Member

ai commented Jun 25, 2012

I wait for you if git version will fix all issues for you and then release version 1.0.1.

@akzhan
Copy link
Contributor

akzhan commented Jun 25, 2012

@ai what to do when I don't override any :translations setting? Is it covered by your patch?

@ai
Copy link
Member

ai commented Jun 25, 2012

@akzhan yes, patch may help (if problem was in some strange loading order, when R18n plugin get wrong app root path), but I am sorry, I didn’t know exactly.

@mitfik
Copy link
Author

mitfik commented Jun 25, 2012

Thanks a lot it works right now.

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

3 participants