Skip to content

Instantly share code, notes, and snippets.

@DmytroVasin
DmytroVasin / routes.rb
Last active October 25, 2017 14:45
Non splited file
require 'sidekiq/web'
Sidekiq::Web.use Rack::Auth::Basic do |username, password|
# NOTE: https://github.com/mperham/sidekiq/wiki/Monitoring
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(username), ::Digest::SHA256.hexdigest(ENV.fetch('ADMIN_NAME'))) &
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(password), ::Digest::SHA256.hexdigest(ENV.fetch('ADMIN_PASSWORD')))
end if Rails.env.production?
Rails.application.routes.draw do
mount Sidekiq::Web, at: '/sidekiq'
@DmytroVasin
DmytroVasin / purchased_image_uploader.rb
Created October 21, 2017 13:03
Carrierwave bug with version inheritance. ( Part 3 )
class PurchasedImageUploader < ImageUploader
def store_dir
"purchased_image/#{model.id}"
end
version :small do
def store_dir
"purchased_image/#{model.id}"
end
@DmytroVasin
DmytroVasin / purchased_image_uploader.rb
Last active October 21, 2017 12:21
Carrierwave bug with version inheritance. ( Part 2 )
class PurchasedImageUploader < ImageUploader
def store_dir
"purchased_image/#{model.id}"
end
end
@DmytroVasin
DmytroVasin / image_uploader.rb
Last active October 21, 2017 12:20
Carrierwave bug with version inheritance. ( Part 1 )
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"image/#{model.id}"
end
version :small do
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
export BUNDLER_EDITOR="/usr/local/bin/subl"
export EDITOR="/usr/local/bin/subl"
### Added by the Heroku Toolbelt
export PATH="$HOME/.rvm/bin:$PATH"
export PATH="/usr/local/heroku/bin:$PATH"
export PATH="/usr/local/bin:$PATH"
export PATH="/usr/local/sbin:$PATH"
### Yarn:
export PATH="$HOME/.config/yarn/global/node_modules/.bin:$PATH"
class TripReservationsController < ApplicationController
def create
reservation = TripReservation.new(params[:trip_reservation])
trip = Trip.find_by_id(reservation.trip_id)
agency = trip.agency
payment_adapter = PaymentAdapter.new(buyer: current_user)
unless current_user.can_book_from?(agency)
redirect_to trip_reservations_page, notice: TripReservationNotice.new(:agency_rejection)
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rails", github: "rails/rails"
@DmytroVasin
DmytroVasin / .railsrc
Created April 8, 2017 18:38
number of “flags” which will provide some initial customizations for the new project
--database=postgresql
--skip-action-cable
--skip-spring
--skip-coffee
--skip-turbolinks
@DmytroVasin
DmytroVasin / Assets be_undefined_in_js (Rspec)
Last active February 28, 2017 19:07
Extend Rspec to include additional matcher.
describe "Assets", type: :feature, js: true do
describe "application.js" do
it "does not include page-specific content" do
visit root_path
expect("d3").to be_undefined_in_js
expect("moment").to be_undefined_in_js
end
end