Skip to content

Instantly share code, notes, and snippets.

@ugisozols
ugisozols / application.rb
Created September 6, 2011 14:25
assets lazily compiled in production
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
# Bundler.require *Rails.groups(:assets => %w(development test))
# If you want your assets lazily compiled in production, use this line
Bundler.require(:default, :assets, Rails.env)
end
@kirs
kirs / gist:1180272
Created August 30, 2011 05:51
NginX config for Rails 3.1 & Unicorn
upstream example_backend {
server unix:/var/www/example.com/shared/unicorn.sock;
}
server {
listen 80;
server_name example.com www.example.com;
access_log off;
error_log off;
client_max_body_size 20M;

RailsAdmin and Globalize3

I have a project where I need translated content. Therefore I use globalize3, wich stores its translated attributes in a seperate table that belongs to the original model. And I use RailsAdmin for painless record management.

It took me some time to figure out how to get those working together, but eventually I found a solution that is non invasive and still ok to work with.

The translated model

In my case there is a Snippet class. It holds content for static pages or text passages on the website. There is a good README for globalize3 for installation instructions and documentation.

@Overbryd
Overbryd / rails_admin_and_globalize3.md
Created July 14, 2011 20:31
RailsAdmin and Globalize3

RailsAdmin and Globalize3

I have a project where I need translated content. Therefore I use globalize3, wich stores its translated attributes in a seperate table that belongs to the original model. And I use RailsAdmin for painless record management.

It took me some time to figure out how to get those working together, but eventually I found a solution that is non invasive and still ok to work with.

The translated model

In my case there is a Snippet class. It holds content for static pages or text passages on the website. There is a good README for globalize3 for installation instructions and documentation.

@johnthethird
johnthethird / cap_notify.rb
Created May 4, 2011 20:02 — forked from rtekie/cap_notify.rb
Capistrano deployment email notifier for Rails 3
=begin
Capistrano deployment email notifier for Rails 3
Do you need to send email notifications after application deployments?
Christopher Sexton developed a Simple Capistrano email notifier for rails. You can find details at http://www.codeography.com/2010/03/24/simple-capistrano-email-notifier-for-rails.html.
Here is Rails 3 port of the notifier.
The notifier sends an email after application deployment has been completed.
@PanosJee
PanosJee / refinery_omniauth.rb
Created March 17, 2011 22:58
Login / Register to Refinery with Omniauth (facebook, twitter, openid, etc)
# Create a role user (no perms). Fire up the console rails c
$> Role.create(:title=>'User')
# In your Gemfile add
gem 'oa-oauth', :require => 'omniauth/oauth'
# At the beginning of devise.rb. You can also create a yaml file and instantiate when Rails begin
# For shake of simplicity I added the credentials at devise.rb
Facebook = Rails.env.development? ? {:app_id => 2621xxx, :secret => 'e81f33d042xxxxx'} :
{:app_id => 1749xxx9, :secret => '13c11be6628dc1xxxx'}
module CML2
# Includes to ProductCategory model
module ProductCategory
def import node_set
::ProductCategory.delete_all
::ProductCategory.import_categories \
node_set.xpath('/КоммерческаяИнформация/Классификатор/Группы')
end
@schof
schof / ability_decorator.rb
Created October 29, 2010 03:15
Add custom cancan abilities on top of Spree
class AbilityDecorator
include CanCan::Ability
def initialize(user)
#############################
can :destroy, LineItem do |item|
item.order.user == user
end
#############################
can :read, Artwork do |artwork|
@cmaujean
cmaujean / spree-extension-cap-tasks.rb
Created October 17, 2010 00:29
A set of extension management related tasks for using Capistrano on a spreecommerce install. For spree-0-11-stable.
# Spree extension capistrano tasks
# --------------------------------
# by Christopher Maujean
#
# These tasks depend on the existence of the extensions hash.
# The key is name of the directory in vendor/extensions.
# The value is the git url of the extension.
#
# set :extensions, {
# 'my_site' => "git@github.com:/username/spree-my-site.git"
@kakra
kakra / filter_payment_methods.rb
Created October 14, 2010 22:10
Filter payment methods in Spree depending on the shipping name
# Filter payment methods in Spree depending on the shipping name,
# use the following snippet within your activation method to
# make it work:
#
# CheckoutsController.class_eval { include FilterPaymentMethods }
#
# The magic happens within the InstanceMethods module, change the
# regexp to fit your needs.
#
# Kai Krakow, http://github.com/kakra