Skip to content

Instantly share code, notes, and snippets.

View Antiarchitect's full-sized avatar
💭
Single

Andrey Voronkov Antiarchitect

💭
Single
View GitHub Profile
class Dcp < Program
...
def after_initialize
ids = Array.new
unless (all_subprograms = subprograms.all(:select => 'id')).nil?
all_subprograms.each do |subprogram|
ids << subprogram.id
end
script_console_running = ENV.include?('RAILS_ENV') && IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers')
rails_running = ENV.include?('RAILS_ENV') && !(IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers'))
irb_standalone_running = !script_console_running && !rails_running
if script_console_running
require 'logger'
Object.const_set(:RAILS_DEFAULT_LOGGER, Logger.new(STDOUT))
end
class Event < ActiveRecord::Base
extend ActiveSupport::Memoizable
cattr_accessor :year
belongs_to :program
has_many :financing_periods, :dependent => :destroy
def current_period
financing_periods.current(@@year).last(:include => [:plain_financings, { :named_financings => :district }])
@Antiarchitect
Antiarchitect / method_factory
Created November 7, 2010 14:04
Alternative way of method factory
Financing::FINANCINGS.each do |method|
define_method method do
if current_period && current_period != :nil
instance_variable_defined?("@#{method}") ? nil : instance_variable_set("@#{method}", Hash.new)
instance_variable_get("@#{method}")[current_period.id] ||= current_period.method("#{method}").call
else
0.0
end
end
end
// Здесь представлен пример использования json ответа от контроллера ClassroomsController как источника данных для autocomplete, входящего в набор jQuery UI.
$('#classroom_name').change(function () {
$(this).autocomplete('disable'); // These two lines fixes bug with simultaneously
$(this).autocomplete('enable'); // opening two same auditories at once (on fast clicking)
});
$('#classroom_name').autocomplete({
disabled: false,
source: function(request, response) {
$.getJSON('/editor/classrooms.json', {
authorization do
role :guest do
has_permission_on :authorization_rules, :to => :read
has_permission_on [:users, :favorites], :to => [:index]
#USER
has_permission_on :users, :to => :create
has_permission_on :users, :to => [:show] do
if_attribute :settings => {:show_profile => is {true}}
end
script_console_running = ENV.include?('RAILS_ENV') && IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers')
rails_running = ENV.include?('RAILS_ENV') && !(IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers'))
irb_standalone_running = !script_console_running && !rails_running
if script_console_running
require 'logger'
Object.const_set(:RAILS_DEFAULT_LOGGER, Logger.new(STDOUT))
end
script_console_running = ENV.include?('RAILS_ENV') && IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers')
rails_running = ENV.include?('RAILS_ENV') && !(IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers'))
irb_standalone_running = !script_console_running && !rails_running
if script_console_running
require 'logger'
Object.const_set(:RAILS_DEFAULT_LOGGER, Logger.new(STDOUT))
end
require 'spec_helper'
describe "Edit profile process" do
before(:each) do
@user = Factory.create(:user)
@user.confirm!
@login_button = I18n.t("devise.sessions.new.submit")
@edit_button = I18n.t("devise.registrations.edit.submit")
@login_link = I18n.t("devise.menu.login_items.login")
@logout_link = I18n.t("devise.menu.login_items.logout")
# Русский перевод для https://github.com/plataformatec/devise/tree/v1.4.7
# Другие переводы на http://github.com/plataformatec/devise/wiki/I18n
ru:
errors:
messages:
expired: "устарела. Пожалуйста, запросите новую"
not_found: "не найдена"
already_confirmed: "уже подтверждена. Пожалуйста, попробуйте войти в систему"
not_locked: "не заблокирована"