Code Monkey home page Code Monkey logo

urbanautomaton / friendly_id Goto Github PK

View Code? Open in Web Editor NEW

This project forked from norman/friendly_id

0.0 3.0 1.0 2.29 MB

FriendlyId is the “Swiss Army bulldozer” of slugging and permalink plugins for ActiveRecord. It allows you to create pretty URL’s and work with human-friendly strings as if they were numeric ids for ActiveRecord models.

Home Page: http://rubydoc.info/github/norman/friendly_id/master/frames

License: MIT License

Ruby 100.00%

friendly_id's Introduction

FriendlyId

Build Status

FriendlyId is the "Swiss Army bulldozer" of slugging and permalink plugins for Ruby on Rails. It allows you to create pretty URLs and work with human-friendly strings as if they were numeric ids for Active Record models.

Using FriendlyId, it's easy to make your application use URLs like:

http://example.com/states/washington

instead of:

http://example.com/states/4323454

FriendlyId Features

FriendlyId offers many advanced features, including: slug history and versioning, i18n, Globalize support, scoped slugs, reserved words, and custom slug generators.

FriendlyId is compatible with Active Record 3.0 and higher.

Version 4.x

FriendlyId 4.x introduces many changes incompatible with 3.x. If you're upgrading, please read the docs to see what's new.

Docs

The current docs can always be found here.

The best place to start is with the Guide, which compiles the top-level RDocs into one outlined document.

You might also want to watch Ryan Bates's Railscast on FriendlyId.

Rails Quickstart

gem install friendly_id

rails new my_app

cd my_app

gem "friendly_id", "~> 4.0.1"

rails generate scaffold user name:string slug:string

# edit db/migrate/*_create_users.rb
add_index :users, :slug, unique: true

rake db:migrate

# edit app/models/user.rb
class User < ActiveRecord::Base
  extend FriendlyId
  friendly_id :name, use: :slugged
end

User.create! name: "Joe Schmoe"

rails server

GET http://localhost:3000/users/joe-schmoe

# If you're adding FriendlyId to an existing app and need
# to generate slugs for existing users, do this from the
# console, runner, or add a Rake task:
User.find_each(&:save)

Benchmarks

The latest benchmarks for FriendlyId are maintained here.

Bugs

Please report them on the Github issue tracker for this project.

If you have a bug to report, please include the following information:

  • Version information for FriendlyId, Rails and Ruby.
  • Full stack trace and error message (if you have them).
  • Any snippets of relevant model, view or controller code that shows how you are using FriendlyId.

If you are able to, it helps even more if you can fork FriendlyId on Github, and add a test that reproduces the error you are experiencing.

For more info on how to report bugs, please see this article.

Thanks and Credits

FriendlyId was originally created by Norman Clarke and Adrian Mugnolo, with significant help early in its life by Emilio Tagua. I'm deeply gratful for the generous contributions over the years from many volunteers.

Part of the inspiration to rework FriendlyId came from Darcy Laycock's library Slugged, which he was inspired to create because of frustrations he experienced while using FriendlyId 3.x. Seeing a smart programmer become frustrated with my code was enough of a kick in the butt to make me want to significantly improve this library.

Many thanks to him for providing valid, real criticism while still being a cool about it. I definitely recommend you check out his library if for some reason FriendlyId doesn't do it for you.

Thanks also to Loren Segal and Nick Plante for YARD and the rubydoc.info website which FriendlyId uses for documentation.

Lastly, FriendlyId uses Travis for continuous integration. It's an excellent, free service created by a whole bunch of good people - if you're not already using it, you should be!

License

Copyright (c) 2008-2012 Norman Clarke and contributors, released under the MIT license.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

friendly_id's People

Contributors

aduffeck avatar amerine avatar bensie avatar dkln avatar empact avatar eric avatar gtd avatar ifesdjeen avatar kamal avatar manuelmeurer avatar mattscilipoti avatar miloops avatar myabc avatar nagybence avatar negonicrac avatar nono avatar norman avatar parndt avatar pixeltrix avatar qhoxie avatar ramon avatar robyurkowski avatar ryanwood avatar seanabrahams avatar shioyama avatar shirkevich avatar slbug avatar spraints avatar technicalpickles avatar xymbol avatar

Watchers

 avatar  avatar  avatar

Forkers

convidera

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.