Skip to content

Instantly share code, notes, and snippets.

View nordringrayhide's full-sized avatar

Nodrin Grayhide nordringrayhide

  • home
  • Worldwide
View GitHub Profile
module InheritedResources
module DefaultActions
def self.included(base)
base.send :extend, ClassMethods
end
module ClassMethods
def default_actions(*actions_to_keep)
options = actions_to_keep.extract_options!
actions_to_keep.map!(&:to_sym).uniq!
source :gemcutter
gem 'rails', '3.0.0'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'haml'
gem 'inherited_resources'
class Signup::CustomersController < ApplicationController
inherit_resources
defaults :resource_class => User, :collection_name => 'users', :instance_name => 'user'
actions :new, :create
def create
create! do |success, failure|
success.html do
resource.roles |= [Role.find_by_name('customer')]
flash[:notice] = "Customer #{resource.name} successfuly registered"
require "ya2yaml"
desc 'Create YAML test fixtures from data in an existing database.'
task 'db:fixtures:dump' => :environment do
sql = "SELECT * FROM %s"
skip_tables = ["schema_info", "schema_migrations"]
ActiveRecord::Base.establish_connection
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
i = "0000000"
File.open("#{RAILS_ROOT}/db/bootstrap/fixtures/#{table_name}.yml", 'w' ) do |file|
#!/usr/bin/env ruby
Dir.glob("config/locales/*.yml") do |locale|
puts "Fixing #{locale}"
content = File.read(locale).gsub(/\{\{(.*?)\}\}/,'%{\1}')
File.open(locale, 'w') { |f| f.write content }
end
require 'autotest/restart' # перезапускати процес при після зміни файла .autotest
require 'redgreen/autotest' # підфарбовування результатів тестів(потрібен гем redgreen)
require 'autotest/growl' # Інтеграція з системою сповіщень ОС
Autotest.add_hook :initialize do |autotest|
%w{.git .svn .hg .DS_Store ._* vendor tmp log doc .swo .swp}.each do |exception|
autotest.add_exception(exception)
end
require 'json'
require 'open-uri'
obj = JSON.parse(open('http://uri-path/to/json/data').read)
/etc/network/interfaces
# DHCP
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
#STATIC IP
#1) Add to your ~/.gitconfig file
#
# [core]
# excludesfile = /home/username/.gitignore
# 2) Create a ~/.gitignore file with file patterns to be ignored
# 3) Save your dot files in another repo so you have a backup (optional).
# $ mv config/database.yml config/databse.yml.example
# Remove files from tracking
---
:bulk_threshold: 1000
:backtrace: false
:sources:
- http://gemcutter.org
- http://gems.github.com
- http://gems.rubyforge.org/
:benchmark: false
:update_sources: false
:verbose: true