Skip to content

Instantly share code, notes, and snippets.

@mohitjain1
mohitjain1 / account_setup.rb
Created March 4, 2013 10:20
default module
module AccountSetup
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
end
end
@mohitjain1
mohitjain1 / gist:5020587
Created February 23, 2013 17:29
devise modules
devise :database_authenticatable, :registerable,:async,
:recoverable, :rememberable, :trackable, :validatable, :token_authenticatable, :confirmable
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'gifts_growth'
},
title: {
<%= javascript_include_tag 'highcharts' %>
<%= javascript_include_tag 'exporting' %>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'growth_rate'
@mohitjain1
mohitjain1 / act_as_countable.rb
Created February 23, 2013 17:26
act as countable module
module ActAsCountable
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def total_records_counts_array_in_past_n_days(range = 30.days)
total_records = []
counts = self.group('Date(created_at)').count
(30.days.ago.to_date..Date.today).each do |day|
@mohitjain1
mohitjain1 / database.yml
Created February 23, 2013 17:26
example database yml
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
@mohitjain1
mohitjain1 / deploy.rb
Created February 23, 2013 17:24
deploy script
set :stages, %w(production staging) #various environments
load "deploy/assets" #precompile all the css, js and images... before deployment..
require "bundler/capistrano" # install all the new missing plugins...
require 'capistrano/ext/multistage' # deploy on all the servers..
require "rvm/capistrano" # if you are using rvm on your server..
require './config/boot'
require 'delayed/recipes' # load this for delayed job..
require "whenever/capistrano"
require './config/boot'
require 'airbrake/capistrano'
@mohitjain1
mohitjain1 / dashboard.rb
Created February 23, 2013 17:22
Dashboard for admin panel
ActiveAdmin.register_page "Dashboard" do
sidebar :help do
ul do
li "Stuck? Contact your manager"
li "or drop a mail at [email protected]"
end
end
menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") }
@mohitjain1
mohitjain1 / Gemfile
Created February 23, 2013 17:21
Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.11'
gem 'mysql2'
gem 'rake', '0.9.2.2'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
class ApplicationController < ActionController::Base
#protect_from_forgery
before_filter :authenticate_user!
before_filter :block_whole_all_requests_in_case_welcome_flow_not_completed
# helper_method :user_is_report_manager?, :user_is_group_member?, :user_is_manager_or_owner?
# ===================