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

Products groups permalink translated from russian with letter "Ь" #1

Open
deemytch opened this issue Mar 12, 2012 · 0 comments
Open

Comments

@deemytch
Copy link

/cc biow0lf

moved from spree/spree#1232 (comment)

spree 1.0, rails 3.1.3, postgresql, linux x64

When creating products group in admin interface, if name is entered on russian with letter "Ь" (soft sign) with have to be translated (why?) to single quote, for ex. "Обувь (shoes) -> Obuv' " this parameter gets passed directly to postgresql in a form

"e_product_groups"  WHERE (permalink LIKE 'Obuv'%') ORDER" etc

that sure throws an error.

In ROR2RU google group user Solenko suppose:
( https://groups.google.com/forum/?fromgroups#!topic/ror2ru/yfGFuZb2B60 )

https://github.com/spree/spree/blob/master/core/lib/spree/core/permalinks.rb#L43

:conditions => "#{field} LIKE '#{permalink_value}%'",

fix

:conditions => ["#{field} LIKE '?'", "#{permalink_value}%"],

BUT I think for the correct translation for permalinks is better to get out from any quotes at all, because of unpredictable manner of appearance of new errors when using quotes and other special symbols in names.

This solved the problem for me:

/app/config/initializers/stringex.rb

class String
  def to_url
    remove_formatting.downcase.gsub(/[ъЪьёЁєЄЇїіІ \'\"\%\.\;\:]+/, '_' ).gsub(/_+/,'_').parameterize
  end
end
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

1 participant