Skip to content

Instantly share code, notes, and snippets.

View joshmn's full-sized avatar
🔒
@ FCI Thompson

joshmn joshmn

🔒
@ FCI Thompson
View GitHub Profile
@developer88
developer88 / active_admin.rb
Last active March 19, 2016 20:18
This is my gist that show how we can use CanCan with ActiveAdmin and store permissions in database.
# config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
config.current_user_method = :current_user
config.authentication_method = :authenticate_user!
config.before_filter :admin_role_filter
end
# Adding all recource names to Permissions table after ActiveAdmin is loaded
@JangoSteve
JangoSteve / ubuntu_rails_install.rb
Created January 22, 2011 17:58
Capistrano script to install Ruby, RVM, Rails in ubuntu (modified from deploy.rb scripts)
namespace :ubuntu do
desc "Setup Environment"
task :setup_env, :roles => :app do
update_apt_get
install_dev_tools
install_git
install_subversion
install_sqlite3
# Install and setup RVM instead of old Rails stack
#install_rails_stack
@raedatoui
raedatoui / gist:2055952
Created March 17, 2012 07:05
active admin sort by association
### Model
class ModelA < ActiveRecord::Base
has_many :modelb
end
class ModelB < ActiveRecord::Base
belongs_to :modela
has_many :modelc
end
@tzvetkoff
tzvetkoff / gist:7287456
Last active January 8, 2019 06:44
Make it more test-ish
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', :github => 'rails/rails'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
class Customers::GridCountsController < ApplicationController
def index
render json: GridCountsQuery.run(params[:grid_counts])
end
end
class GridCountsQuery
class << self
def run
query.each_with_object(Hash.new) do |row, grid|
@sineed
sineed / ams.rb
Last active June 10, 2020 15:42
Upgrade AMS from 0.9.0 to 0.10.0
module AMS
module V09
class Serializer < ActiveModel::Serializer
def serializable_hash(adapter_options = nil,
options = {},
adapter_instance = self.class.serialization_adapter_instance)
object.nil? ? nil : super
end
end
@stouset
stouset / LICENSE
Last active May 27, 2022 16:46
Best-practices based API key authentication
Copyright © 2021 Stephen Touset <stephen@touset.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SO
@mhenrixon
mhenrixon / _form.html.haml
Created May 18, 2011 11:02
A complete sample of how to perform nested polymorphic uploads in rails using carrierwave
=semantic_form_for [:admin, @dog], validate: true, html: {multipart: true} do |f|
=f.inputs do
=f.input :name
=f.input :kennel_name
=f.input :birthdate
=f.input :gender, as: :radio, collection: {'Tik' => 'F', 'Hane' => 'M'}
=f.input :father_id, as: :select, collection: @dogs
=f.input :mother_id, as: :select, collection: @bitches
=f.semantic_fields_for :pictures do |pic|
@andyshinn
andyshinn / Dockerfile
Last active August 8, 2023 08:39
Postal on Docker
FROM ruby:2.3-onbuild
VOLUME /opt/postal/config
ENV LOG_TO_STDOUT 1
ENV AM_CONFIG_ROOT /opt/postal/config
RUN gem install procodile
RUN apt-get update -qq && apt-get install -yqq nodejs