Skip to content

Instantly share code, notes, and snippets.

View lalitlogical's full-sized avatar
💭
I may be slow to respond.

Lalit Kumar Maury lalitlogical

💭
I may be slow to respond.
  • engineer.ai
  • Gurgaon, Haryana, India
View GitHub Profile
@lalitlogical
lalitlogical / carrierwave_aws.rb
Created December 18, 2018 06:10
carrierwave aws
CarrierWave.configure do |config|
if Rails.env.development? or Rails.env.test?
config.asset_host = "http://localhost:#{(ENV['PORT'].try(:to_i) || 3000)}"
config.storage = :file
else
config.storage = :aws
config.aws_bucket = ENV['S3_BUCKET_NAME'] || "contracts-#{Rails.env}"
config.aws_acl = 'public-read'
# Optionally define an asset host for configurations that are fronted by a
@lalitlogical
lalitlogical / database.yml
Created December 18, 2018 06:10
database yml
default: &default
adapter: postgresql
host: <%= ENV['DB_HOST'] %>
encoding: unicode
pool: 5
username: <%= ENV['DB_USERNAME'] %>
password: <%= ENV['DB_PASSWORD'] %>
database: <%= ENV['DB_DATABASE'] %>
template: template0
@lalitlogical
lalitlogical / has_many_through.rb
Last active December 15, 2018 18:11
Custom has many through association in mongo db
module HasManyThrough
extend ActiveSupport::Concern
class_methods do
def define_through associations = {}
class_eval do
associations.each do |model, through_model|
model_name = model.to_s.underscore
define_method "#{model_name}_ids" do
@lalitlogical
lalitlogical / _navbar.html.erb
Created July 4, 2017 10:11
Active proper menu in Rails views
...
<div class="hor-menu ">
<ul class="nav navbar-nav">
<li class="<%= active('dashboard', 'index')%>">
<%=link_to "Dashboard", root_path %>
</li>
<li class="<%= active('organisations,organisation_people')%>">
<%=link_to "Organisations", organisations_path %>
</li>
<li class="<%= active('people')%>">
@lalitlogical
lalitlogical / custom_devise_mailer.rb
Last active March 21, 2017 07:48
Dynamic subject for Devise mailers (i.e. reset_password_instructions)
class CustomDeviseMailer < Devise::Mailer
helper :application # gives access to all helpers defined within `application_helper`.
include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
default template_path: 'devise/mailer' # to make sure that your mailer uses the devise views
def reset_password_instructions(record, token, opts={})
opts[:subject] = I18n.t(:'devise.mailer.reset_password_instructions.subject', app_name: ENV['APP_NAME'])
super
end
end
@lalitlogical
lalitlogical / deploy.rb
Last active April 30, 2017 06:16
sunspot solr with help of capistrano 3
# Your other configuration i.e. github repo, branch, deploy_to etc
.........
namespace :deploy do
# Your other configuration i.e. start/stop puma/passanger/any other application server
......
before :updated, :setup_solr_data_dir do
invoke 'solr:symlink'
end