Skip to content

Instantly share code, notes, and snippets.

View danielwestendorf's full-sized avatar
:shipit:
shipping

Daniel Westendorf danielwestendorf

:shipit:
shipping
View GitHub Profile
class ApplicationController < ActionController::Base
include SimonSays::Authorizer
self.default_authorization_scope = :current_user
end
class Membership < ActiveRecord::Base
include SimonSays::Roleable
belongs_to :user
belongs_to :document
has_roles :download, :edit, :delete,
end
class Admin < ActiveRecord::Base
include SimonSays::Roleable
has_roles :design, :support, :moderator, as: :access
end
Admin.new.access
# => []
Admin.new(access: :support).access
User.new.roles
# => []
User.new.tap { |u| u.roles = :add, :edit }.roles
# => [:add, :edit]
class User < ActiveRecord::Base
include SimonSays::Roleable
has_roles :add, :edit, :delete
end
$ gem install simon_says
$ bundle
gem 'simon_says'
# app/controllers/reports_controller.rb
class ReportsController < ApplicationController
authorize_resource :admin, :support
find_resource :report, from: :current_admin, except: [:index, :new, :create]
end
var magicLibrary = new MagicLibrary();
var images = document.querySelectorAll('img');
// All ye Old browsers Beware
images.forEach(function(img) {
var glorifiedDataURI = magicLibrary.glorify(img);
img.src = glorifiedDataURI;
})