Skip to content

Instantly share code, notes, and snippets.

View Disha-Shah's full-sized avatar

Disha Shah Disha-Shah

  • Ahmedabad, India
View GitHub Profile
@Disha-Shah
Disha-Shah / override_activerecord_validation_errors.yml
Created July 26, 2017 06:41
Rails - Override Activerecord validation errors
activerecord:
attributes:
address:
phone: "Phone"
name: "Street Name"
line1: "Address line 1"
city: "Address line 2"
state: "State"
country: "Country"
pincode: "Pincode"
@Disha-Shah
Disha-Shah / deploy.rake
Created May 9, 2017 07:44 — forked from njvitto/deploy.rake
Rakefile to deploy and rollback to Heroku in two different environments (staging and production) for the same app
#Deploy and rollback on Heroku in staging and production
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
namespace :deploy do
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU'
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU'
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag]
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on]
@Disha-Shah
Disha-Shah / rails_heroku_versioning.md
Last active April 7, 2017 09:51
Rails - Integrating Heroku deployment version in Request header

1.. Enable runtime dyno for Heroku with following command :

heroku labs:enable runtime-dyno-metadata -a app-name

2.. Add custom header for all requests. Make the following change in application.rb

 config.action_dispatch.default_headers.merge!('X-RELEASE-VERSION' => ENV['HEROKU_RELEASE_VERSION'])

You will receive HEROKU_RELEASE_VERSION values after next deployment.

http://easyautocomplete.com/examples // Autocomplete using js
@Disha-Shah
Disha-Shah / staging_production_env_git_heroku.md
Created January 3, 2017 06:53
Create 2 environments - Staging and Production from same App (Heroku and Git)

NOTICE: When I say "appname" it means enter your own! It's not a command or name native to git or Heroku. By default, your one and only remote is called "heroku". This is why you do things like $ git push heroku master, you're pushing to the master branch of heroku. What we want is two remotes: one staging, one production. You can view your remotes by typing...

$ heroku apps:create staging-appname
$ git remote -v 
   // this should return:
   // heroku	git@heroku.com:appname.git (fetch)
   // heroku	git@heroku.com:appname.git (push)

So, lets rename that default heroku git remote to a staging, production one.

require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
context "GET index" do
#context "POST create" do
#context "GET show" do
#context "PATCH update" do (or PUT update)
#context "DELETE destroy" do
#context "GET new" do
@Disha-Shah
Disha-Shah / rspec_model_testing_template.rb
Last active July 6, 2016 11:40 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@Disha-Shah
Disha-Shah / reset_primary_key.md
Last active December 9, 2016 07:40 — forked from paulsturgess/reset_primary_key.md
Reset postgres primary key index using Rails
$ ActiveRecord::Base.connection.reset_pk_sequence!('table_name')

If you need the table names:

$ ActiveRecord::Base.connection.tables
=> ["accounts", "assets", ...]

If you need to reset for all tables:

$ all_tables = ActiveRecord::Base.connection.tables

@Disha-Shah
Disha-Shah / receipt
Created May 24, 2016 11:09 — forked from sauloarruda/receipt
Apple iOS in app purchase validate receipt in Ruby
ewoJInNpZ25hdHVyZSIgPSAiQXBNVUJDODZBbHpOaWtWNVl0clpBTWlKUWJLOEVk
ZVhrNjNrV0JBWHpsQzhkWEd1anE0N1puSVlLb0ZFMW9OL0ZTOGNYbEZmcDlZWHQ5
aU1CZEwyNTBsUlJtaU5HYnloaXRyeVlWQVFvcmkzMlc5YVIwVDhML2FZVkJkZlcr
T3kvUXlQWkVtb05LeGhudDJXTlNVRG9VaFo4Wis0cFA3MHBlNWtVUWxiZElWaEFB
QURWekNDQTFNd2dnSTdvQU1DQVFJQ0NHVVVrVTNaV0FTMU1BMEdDU3FHU0liM0RR
RUJCUVVBTUg4eEN6QUpCZ05WQkFZVEFsVlRNUk13RVFZRFZRUUtEQXBCY0hCc1pT
QkpibU11TVNZd0pBWURWUVFMREIxQmNIQnNaU0JEWlhKMGFXWnBZMkYwYVc5dUlF
RjFkR2h2Y21sMGVURXpNREVHQTFVRUF3d3FRWEJ3YkdVZ2FWUjFibVZ6SUZOMGIz
SmxJRU5sY25ScFptbGpZWFJwYjI0Z1FYVjBhRzl5YVhSNU1CNFhEVEE1TURZeE5U
SXlNRFUxTmxvWERURTBNRFl4TkRJeU1EVTFObG93WkRFak1DRUdBMVVFQXd3YVVI
@Disha-Shah
Disha-Shah / devise.rb
Created May 10, 2016 11:39 — forked from solutelabs-savan/devise.rb
Create Sign In / Sign Out API using Devise
# 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]