Skip to content

Instantly share code, notes, and snippets.

View anna-bucher's full-sized avatar

Anna Bucher anna-bucher

  • switzerland
View GitHub Profile
# site_id AND... OWNER
scope = "nodes.site_id = #{visitor.site.id} AND (nodes.user_id = '#{visitor[:id]}' OR "+
# OR READER if published
"(nodes.rgroup_id IN (#{visitor.group_ids.join(',')}) AND nodes.publish_from <= now() ) OR " +
# OR publisher if status is <> red
"(nodes.pgroup_id IN (#{visitor.group_ids.join(',')}) AND nodes.max_status <> #{Zena::Status[:red]}))"
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index 0fefec1..2f5babe 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -101,6 +101,7 @@ module ActiveRecord
else
build_record(attributes) do |record|
block.call(record) if block_given?
+ record.send(:"#{@owner.class.to_s.underscore}=", @owner) if record.respond_to?(:"#{@owner.class.to_s.underscore}=")
set_belongs_to_association_for(record)
# Returns whether or not the parent, <tt>self</tt>, and any loaded autosave associations are valid.
def valid_with_autosave_associations?
record_valid = valid_without_autosave_associations?
self.class.reflect_on_all_autosave_associations.all? do |reflection|
if (association = association_instance_get(reflection.name)) && association.loaded?
if association.is_a?(Array)
association.proxy_target.all? { |child| autosave_association_valid?(reflection, child) }
else
autosave_association_valid?(reflection, association)
class Value
{
Value() : type_(NIL_TYPE_ID) {}
bool isReal()
{ return type_ == REAL_TYPE_ID; }
// special thing here: anonymous union
union {
real_t r;
/* $Id$ */
/***
This file is part of avahi.
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
/* Copyright: http://textile.thresholdstate.com/ */
function span($text)
{
$qtags = array('\*\*','\*','\?\?','-','__','_','%','\+','~','\^');
$pnct = ".,\"'?!;:";
foreach($qtags as $f) {
$text = preg_replace_callback("/
(?:^|(?<=[\s>$pnct])|([{[]))
// Introduction
// ============
//
// This is the heart of the Metro object: as its 'bang' method is called by a scheduler
// the metro object registers the next call in the scheduler with "bang_me_in" method.
// Things to know
// ==============
//
// 1. object attributes end with an underscore (run_, tempo_)
module Redef
def foo
puts "'foo' from module"
end
end
class A
define_method("foo") do
puts "'foo' from define_method"
end
# real world example in zena: http://github.com/zena/zena/blob/master/lib/zena/acts/secure.rb
# in a module that you include where you need to find
def filter_fields(klass)
scope = {}
find_scope = scope[:find] = {}
find_scope[:select] = klass.fields_for(Thread.current.visitor).map {|f| "#{klass.table_name}.#{f}"}.join(',')
klass.send(:with_scope, scope) { yield }
end
begin
gem 'fast_gettext', '>=0.4.8'
require 'fast_gettext'
rescue LoadError
gem 'grosser-fast_gettext', '>=0.4.8'
end