Skip to content

Instantly share code, notes, and snippets.

class UsersController < Clearance::UsersController
def edit
...
end
end
# in the engine
ActionController::Routing::Routes.draw do |map|
map.resources :users, :controller => 'clearance/users' do |users|
users.resource :password,
:controller => 'clearance/passwords',
:only => [:create, :edit, :update]
end
# in the app
ActionController::Routing::Routes.draw do |map|
has been removed from the module tree but is still active
class Clearance::SessionsController < ApplicationController
unloadable
end
class ActionController::Routing::RouteSet
def load_routes_with_clearance!
clearance_routes = File.join(File.dirname(__FILE__),
*%w[.. config clearance_routes.rb])
unless configuration_files.include? clearance_routes
add_configuration_file(clearance_routes)
end
load_routes_without_clearance!
end
class UsersController < Clearance::UsersController
def edit
...
end
end
ActionController::Routing::Routes.draw do |map|
map.resources :users
end
script/generate clearance_features
class User < ActiveRecord::Base
encrypt_with_public_key :secret,
:key_pair => File.join(RAILS_ROOT,'config','keypair.pem'),
end
user.secret.decrypt 'password'
class ArticleTest < ActiveSupport::TestCase
should_validate_presence_of :title, :abstract, :body, :author
should "submit to crossref after being saved" do
title = 'a title'
request = mock('crossref-request', :submit => true)
CrossrefRequest.
expects(:new).
with(:title => title, ...).
returns(request)
class Article < ActiveRecord::Base
after_create :submit_to_crossref
private
def submit_to_crossref
CrossrefRequest.new(:title => title,
# other info for the request
:author => author).submit
end