Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Railway extension for twitter connect

tree: 02127cfd34

Fetching latest commit…

Cannot retrieve the latest commit at this time


railway install


In application add link to twitter connect /twitter_connect:

<%- link_to("Connect to twitter", '/twitter_connect') %>

By default twitter connect path is /twitter_connect, but it can be configured in config/twitter.yml Callback path can be configured too, see example below.

When app will connected with twitter, global app object will receive message twitterConnect as event emitter, so you can:

app.on('twitterConnect', function (user, req, res) {
   // find or create account for user
   // save user id in req.session
   // redirect user to a proper location

Just put code like this into the environment settings (config/environment.js):

app.on('twitterConnect', function (twitter, req, res) {
    User.findOne({twitterId:}, function (err, user) {
        if (user) {
            req.session.user_id =;
        } else {
            User.register({twitter: twitter});

Ideally, in application should be specific place for stuff like this (maybe app/observers).

Something went wrong with that request. Please try again.