Skip to content

Instantly share code, notes, and snippets.

View zippy's full-sized avatar

Eric Harris-Braun zippy

View GitHub Profile
@zippy
zippy / passwords_controller.rb
Created April 11, 2011 01:17
How to get Devise 1.2 to reset passwords in the case of multiple accounts with the same e-mail
class PasswordsController < Devise::PasswordsController
before_filter :set_request_for_mailer
# POST /resource/password
def create
@resources = User.send_reset_password_instructions(params[resource_name])
self.resource = @resources.is_a?(Array) ? @resources[0] : @resources
if resource.errors.empty?
set_flash_message :notice, :send_instructions
redirect_to new_session_path(resource_name)
@zippy
zippy / gist:863513
Created March 10, 2011 03:09
clojure defmacro problem
(defprotocol T "test" (getclass [this]))
(extend-type clojure.lang.PersistentArrayMap T (getclass [this] (class this)))
(getclass {})
(defmacro makeT [klass] `(extend-type ~klass T (getclass [this] (class this))))
(makeT String)
@zippy
zippy / devise-1-2-x-password-on-confirmation.rb
Created January 9, 2011 13:58
Implementation of getting user password as part of confirmation for Devise 1.2.x
#This is for Devise 1.2.x
# To your routes file add:
as :user do
match '/user/confirmation' => 'confirmations#update', :via => :put, :as=> :update_user_confirmation
end
# Add this inherited confirmations controller as app/controllers/confirmations_controller.rb
@zippy
zippy / devise-1-0-9-password-on-confirmation.rb
Created January 9, 2011 13:41
Implementation of getting user password as part of confirmation for Devise 1.0.9
#This is for Devise 1.0.9
# To your routes file add:
map.update_user_confirmation '/user/confirmation', :controller => 'confirmations', :action => 'update', :conditions => { :method => :put }
# Add this replacement confirmations controller as app/controllers/confirmations_controller.rb
class ConfirmationsController < ApplicationController
@zippy
zippy / gist:768656
Created January 6, 2011 21:43
debugger run of error thrown in #compute_public_path
737 def compute_public_path(source, dir, ext = nil, include_host = true)
738 return source if is_uri?(source)
739
740 source += ".#{ext}" if rewrite_extension?(source, dir, ext)
741 source = "/#{dir}/#{source}" unless source[0] == ?/
=> 742 source = rewrite_asset_path(source, config.asset_path)
743
744 has_request = controller.respond_to?(:request)
745 if has_request && include_host && source !~ %r{^#{controller.config.relative_url_root}/}
746 source = "#{controller.config.relative_url_root}#{source}"