Skip to content

Instantly share code, notes, and snippets.

View stjohncj's full-sized avatar

Chris St. John stjohncj

  • St. John Studios
  • Kewaunee, WI
View GitHub Profile
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render json: user.as_json(auth_token: user.authentication_token, email: user.email), status: :created
return
else
@wrs
wrs / DeviseJsonAdapter.rb
Created December 8, 2010 18:02
JSON-encoded error and redirect results for Devise controllers
# JSON-encoded error and redirect results for Devise controllers.
# This overrides an internal method of Devise, so be careful when updating Devise!
#
# Usage:
#
# class Users::RegistrationsController < Devise::RegistrationsController
# include DeviseJsonAdapter
# end
#
# devise_for :users, :controllers => { :registrations => "users/registrations" }
# Hook our MongoMapper model into Solr
module MongoAdapter
class InstanceAdapter < Sunspot::Adapters::InstanceAdapter
def id
@instance.id
end
end
class DataAccessor < Sunspot::Adapters::DataAccessor
def load(id)
@chadj
chadj / dbd_odbc_patch.rb
Created March 5, 2009 15:46
A monkey patch to fix how DBD::ODBC passes credentials to underlying DB driver
#
# Monkey patch DBD::ODBC to pass usernames and passwords along
# to the DB driver correctly
#
# Are you running a new version of DBI?
begin
require 'dbd/ODBC'
rescue Exception
end