NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths
Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.
NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths
Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.
# An abstract base class used to create simple serializers | |
# for ActiveRecord objects | |
class BaseSerializer | |
include Rails.application.routes.url_helpers | |
attr_reader :serialized_object | |
def initialize(serialized_object) | |
@serialized_object = serialized_object | |
end |
class Runner | |
def run(&block) | |
begin | |
instance_exec(&block) | |
@on_success.call if @on_success | |
rescue Exception => ex | |
@on_failure.call(ex) if @on_failure | |
end | |
end |
class Foo | |
attr_reader :bar | |
def initialize | |
@bar = 123 | |
ObjectSpace.define_finalizer( self, self.class.finalize(bar) ) | |
end | |
def self.finalize(bar) | |
proc { puts "DESTROY OBJECT #{bar}" } | |
end |
require 'openssl' | |
class String | |
def encrypt(key) | |
cipher = OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt | |
cipher.key = Digest::SHA1.hexdigest key | |
s = cipher.update(self) + cipher.final | |
s.unpack('H*')[0].upcase | |
end |
desc 'rolls back migrations in current branch not present in other' | |
task :rollback_branch_migrations, [:other_branch] do |t, args| | |
load "#{Dir.pwd}/Rakefile" | |
branch_migrations = BranchMigrations.new(args.other_branch) | |
puts ['Rollback the following migrations', branch_migrations, 'y,n? '] | |
next if %w[no n NO N].include?(STDIN.gets.chomp) | |
Rake::Task['environment'].invoke |
class ApplicationController < ActionController::Base | |
# Creates an accessor which is exposed to the view | |
def self.view_accessor(*names) | |
attr_accessor *names | |
helper_method *names | |
end | |
end |
=== Часть 1. Обзорная информация | |
== Обязательно посмотрите | |
http://en.wikipedia.org/wiki/Internet_media_type | |
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes или http://www.flickr.com/photos/girliemac/sets/72157628409467125 | |
http://api.rubyonrails.org/classes/ActionDispatch/Response.html | |
http://api.rubyonrails.org/classes/ActionDispatch/Request.html | |
== Документация по AJAX в jQuery |
=== Часть 1. Обзорная информация | |
== Обязательно посмотрите | |
http://en.wikipedia.org/wiki/Internet_media_type | |
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes или http://www.flickr.com/photos/girliemac/sets/72157628409467125 | |
http://api.rubyonrails.org/classes/ActionDispatch/Response.html | |
http://api.rubyonrails.org/classes/ActionDispatch/Request.html | |
== Документация по AJAX в jQuery |
module Abilities | |
def self.ability_for(user) | |
if user.admin? | |
AdminAbility.new(user) | |
else user | |
MemberAbility.new(user) | |
else | |
GuestAbility.new | |
end | |
end |