Skip to content

Instantly share code, notes, and snippets.

@ognevsky
Created December 3, 2012 13:08
Show Gist options
  • Save ognevsky/4194948 to your computer and use it in GitHub Desktop.
Save ognevsky/4194948 to your computer and use it in GitHub Desktop.
Passportist Bootstrap Application
gem 'passportist'
gem 'rails_config'
generate 'rails_config:install'
remove_file('config/settings/development.yml')
create_file('config/settings/development.yml') do
<<-EOF
passport:
url: 0.0.0.0:3000
EOF
end
route <<-EOF
mount Passportist::Engine, at: '/passportist'
EOF
access_token = SecureRandom.hex
initializer('passportist.rb') do
<<-EOF
Passportist.access_token = '#{access_token}'
EOF
end
create_file("db/migrate/#{Time.now.utc.strftime('%Y%m%d%H%M%S')}_create_users.rb") do
<<-EOF
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :uid
t.string :token
t.string :email
t.string :name
t.string :nickname
t.timestamps
end
add_index :users, :uid
end
end
EOF
end
create_file('app/models/user.rb') do
<<-EOF
class User < ActiveRecord::Base
attr_accessible :uid, :token, :email, :name, :nickname, as: :passportist
end
EOF
end
remove_file('public/index.html')
remove_file('app/assets/images/rails.png')
say "Your access token is: #{access_token}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment