This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source :gemcutter | |
gem 'rails', '3.0.0' | |
gem 'sqlite3-ruby', :require => 'sqlite3' | |
gem 'haml' | |
gem 'inherited_resources' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'open-uri' | |
obj = JSON.parse(open('http://uri-path/to/json/data').read) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/etc/network/interfaces | |
# DHCP | |
auto lo | |
iface lo inet loopback | |
auto eth0 | |
iface eth0 inet dhcp | |
#STATIC IP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
:bulk_threshold: 1000 | |
:backtrace: false | |
:sources: | |
- http://gemcutter.org | |
- http://gems.github.com | |
- http://gems.rubyforge.org/ | |
:benchmark: false | |
:update_sources: false | |
:verbose: true |