Skip to content

Instantly share code, notes, and snippets.

View prdetective's full-sized avatar

Vladimir Krivchenko prdetective

View GitHub Profile
@palkan
palkan / 01_Readme.md
Last active April 30, 2023 00:03
Backport Rails 6 per-environment credentials

Backport Rails 6 per-environment credentials to Rails 5.2

Rails PR: rails/rails#33521

This patch makes it possible to use per-environment credentials (i.e., config/credentials/staging.yml.enc) in Rails 5.2.

Installation

  • Drop backport_rails_six_credentials.rb and backport_rails_six_credentials_command.rb somewhere, for example, into the lib/ folder
  • Add this line to config/application.rb:
@roolo
roolo / Error
Created May 6, 2013 11:30
Fix for RMagick 2.12.2 vs. ImageMagick. Mac, Homebrew
Can't install RMagick 2.12.2. Can't find the ImageMagick library or one of the dependent libraries. Check the mkmf.log file for more detailed information.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
@developer88
developer88 / some_active_admin_resource.rb
Created March 5, 2013 13:49
Add custom method to export table as CSV file for ActiveAdmin Resource + scope items from filter + save csv file compatible with Russian Microsoft Office Excel
filter :reception_reception_date, as: :date_range, label: Reception.human_attribute_name(:reception_date_full)
collection_action :download_report, :method => :get do
services = Service.includes(:order, reception: [{medic: :clinic_medics}]).where{ orders.orderable_id != nil } # necessary model
if params[:q] && params[:q][:reception_reception_date_gte].length > 1
services = services.where("receptions.reception_date >= ?", params[:q][:reception_reception_date_gte])
end
if params[:q] && params[:q][:reception_reception_date_lte].length > 1
services = services.where("receptions.reception_date < ?", params[:q][:reception_reception_date_lte])
end