0.01
No commit activity in last 3 years
No release in over 3 years
Make your ActiveRecord IDs non-obvious
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 3.2
~> 0.0.3
 Project Readme

obfuscatable

Gem Version Dependency Status Build Status Code Climate

Make your ActiveRecord ids non-obvious

This gem is just a fork from obfuscate_id but I made the obfuscation optional because it affects to some conditions and causes errors.

Installation

Add the gem to your Gemfile.

gem "obfuscatable"

Run bundler.

bundle install

Usage

In your model, add a single line.

class Post < ActiveRecord::Base
  obfuscatable
end

Then use it with to_param or direct object passing in the view.

link_to 'Post', post_path(@post.to_param)
link_to 'Post', post_path(@post)

And in your controller.

class PostController < ApplicationController
  def show
    Post.find(params[:id], obfuscated: true)
  end
end

Customization

If you want your obfuscated ids to be different than some other website using the same plugin, you can throw a random number (spin) at obfuscatable to make it hash out unique ids for your app.

class Post < ActiveRecord::Base
  obfuscatable :spin => 89238723
end