Skip to content
Railway extension for twitter connect
Find file
Pull request Compare This branch is 3 commits behind 1602:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


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

Example of app/observers/twitter_observer:

app.on('twitterConnect', function (twitter, req, res) {
    User.findOne({twitterId:}, function (err, user) {
        if (user) {
            req.session.user_id =;
        } else {
            User.register({twitter: twitter});
Something went wrong with that request. Please try again.