This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AuthHelper | |
def http_login | |
user = 'username' | |
pw = 'password' | |
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw) | |
end | |
end | |
module AuthRequestHelper | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :postgres do | |
desc 'Backup postgres database' | |
task :backup => :environment do | |
db_config = Rails.application.config.database_configuration[Rails.env] | |
backup_dir = '/home/deploy/backups' | |
outfile = "#{ backup_dir }/#{ Rails.env }_#{ DateTime.now.strftime("%Y%m%d_%H%M%S.sql.gz") }" | |
cmd = "pg_dump -h localhost -U #{ db_config['username'] } #{ db_config['database'] } | gzip -c > #{outfile}" | |
puts "Making database backup..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/tasks/db.rake | |
namespace :db do | |
desc "Dumps the database to db/APP_NAME.dump" | |
task :dump => :environment do | |
cmd = nil | |
with_config do |app, host, db, user| | |
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump" | |
end | |
puts cmd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install Redis on ubuntu first | |
1) Add PPA | |
$ sudo add-apt-repository ppa:chris-lea/redis-server | |
Press ENTER to accept the repository. | |
2) Run the following command to update our packages: | |
$ sudo apt-get update | |
3) Install the Redis server: | |
$ sudo apt-get install redis-server | |
4) Check that Redis is up and running: | |
$ redis-benchmark -q -n 1000 -c 10 -P 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find this line config.navigational_formats = ['*/*', :html] in devise.rb file and replace it with this line inorder to accept JSON request and give JSON response. | |
config.navigational_formats = ["*/*", :html, :json] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |