Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Social features in a rails engine

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 config
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec
Octocat-spinner-32 README
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 sociopathor.gemspec
# What ?

Sociopathor is a rails engine that bundle ready to use implementation of authlogic
and authlogic-connect, to register / login on your app with facebook and twitter.
Once installed, the only thing you need to do is to give your api keys and secrets.

I created it in order not to have to recode this each times, so I only put in the
services I needed (twitter and facebook) among the large panel of services supported
by authlogic.

If you need more sociopathy, well, fork it.

# Install

In your Gemfile, put :
  gem 'sociopathor', :git => 'git://'

Then run :
  bundle install
  rails generate sociopathor:install
  rake db:migrate

# Config

Sociopathor use authlogic-connect, and should be configured as that one.
Two files will be installed :

Enter your api key / secrets in both.

# Use

Sociopathor gives you two ApplicationController methods to use with filters :
- require_user : redirect to login page if user isn't logged in
- require_no_user : redirect to root page and inform user she should not be logged in

He also gives you three helpers methods :
- store_location : store the current url in order to redirect back to it then
- redirect_back_or_default : redirect to stored location or to default given as parameter
- current_user : retrieve the current user instance (or nil)

The User model give you following methods :
- twitter_restful : proxy to twitter api ( or nil if user is not logged in with twitter )
- facebook_restful : proxy to facebook api ( or nil if user is not logged in with facebook )
- profile : a hash containing profile for default (first connected) third party service :
  * id : the user id at third party
  * name : the name of user at third party
  * avatar : the user avatar
  * link : the user profile url at third party

Finally, he also gives you the following routes (not sot antisocial, after all):
- /login
- /logout

# Extend

You'll probably want to extend the base classes. Sociopathor being a rails engine, you
can't just monkey patch them : if an app/models/user.rb file exists in your app, the
engine's one won't be loaded.

That's ok, this mechanism let you override views. Sociopathor generator installs a
bunch of files for you to extend its base class :

If you don't need them, you can safely erase them.

Something went wrong with that request. Please try again.