Git Product home page Git Product logo

chinese_slug's Introduction

chinese_slug

给String添加to_chinese_slug method 用来转换中文网址,主要是去掉特殊字符,比如?%。完整列表可以去lib folder里看。

因为不是app自己的bussiness logic,所以分出来了。

安装

gem install chinese_slug 或者把 gem 'chinese_slug' 加到 Gemfile 里然后运行 bundle install

用法

"白月光石12MM 重41克 10MM重25.6克 欢迎咨询克价".to_chinese_slug

结果:白月光石12MM-重41克-10MM重25-6克-欢迎咨询克价

config/initializers/friendly_id.rb 里加上(一开始这些是comment掉得):

...
  config.use :slugged
...
...
  config.use Module.new {
    def normalize_friendly_id(text)
      text.to_chinese_slug
    end
  }
...

Licence

MIT

chinese_slug's People

Contributors

umhan35 avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.