Skip to content

mindtonic/URL-Shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

URL-Shortener

This mixin for ActiveRecord creates a YouTube like url extensions, obstensively masking your record's id number.

To use, add a migration to the desired model that creates a string called :passkey, and be sure you index it!

def change
  add_column :my_table_name, :passkey, :string
  add_index  :my_table_name, :passkey
end

Then simply include the mixin in the model.

class MyModel < ActiveRecord::Base
  include UrlShortener

  ...
end

The mixin will automatically save the passkey upon create.

It also provides a scope called :by_passkey that you can use as a finder method.

MyModel.by_passkey("eXaMp1E")

About

An ActiveRecord mixin for creating shortened URL's

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages