Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

WatersOfOblivion-niceids

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

WatersOfOblivion-niceids

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

=NiceIds

The NiceIds plugin allows for human readable ids in URLs. By declaring which attribute you wish to be used as the +id+ in your ActiveRecord model, the NiceIds plugin overrides the +to_param+ and +find+ methods to use that parameter:

Users have nice IDs

class Users < ActiveRecord::Base nice_id :username end

Create a user

user = User.new :username => "jdoe"

The original find still works

user == User.find(user.id) # => true

Can be found using the "username" attribute

user == User.find(user.username) # => true

Also overrides to_param

user.to_param # => "jdoe"

The URL-ized form of the property is stripped of all non-alphanumeric characters, all letters are lowercased, and all empty spaces are replaced with dashes:

user = User.new :username => "Don't ever use this as a username!!!" user.to_param # => "dont-ever-use-this-as-a-username"

The nice id is stored in the database in a column named "nice_id". To change the name of the column, use the :column attribute:

Using an alternate column for the nice id field

class User < ActiveRecord::Base nice_id :username, :column => "mean_id" end

Copyright (c) 2009 Jonathan Bryant, released under the MIT license

FAQs

Package last updated on 11 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc