Skip to content

Instantly share code, notes, and snippets.

View lacco's full-sized avatar

Kai Schlichting lacco

  • Germany, Berlin
View GitHub Profile
module AfterCommitCallbacks
def self.included(base)
base.send(:extend, ObserverCallbacks) unless base.respond_to?(:define_model_callbacks_for_observers)
[:create, :update, :destroy].each do |action|
base.send(:define_model_callbacks_for_observers, :"commit_on_#{action}", :only => :after)
end
base.send(:attr_accessor, :newly_created)
base.send(:before_validation, AfterCommitCallbacks::Handlers)
--- a/src/resources/apps/fr/includes/persistence-model.xml
+++ b/src/resources/apps/fr/includes/persistence-model.xml
@@ -121,6 +121,14 @@
<xforms:action if="$form-data">
<xxforms:variable name="xml-data" select="saxon:parse(saxon:base64Binary-to-string(xs:base64Binary($form-data), 'UTF-8'))"/>
<xforms:insert nodeset="xxforms:instance('fr-form-instance')" origin="$xml-data"/>
+ <xforms:rebuild model="fr-form-model"/>
+ <xforms:recalculate forceRecalculateDefaults="true" model="fr-form-model"/>
+ <xforms:revalidate model="fr-form-model"/>
+ <xforms:refresh model="fr-form-model"/>
Initializing Resource Manager with: {oxf.resources.factory=org.orbeon.oxf.resources.PriorityResourceManagerFactory, oxf.resources.filesystem.sandbox-directory=src/resources-packaged, oxf.resources.priority.1=org.orbeon.oxf.resources.FilesystemResourceManagerFactory, oxf.resources.priority.2=org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory}
2010-04-27 23:29:47,422 INFO XFormsToXHTMLConverter - Running processor
2010-04-27 23:29:48,799 ERROR org.orbeon.oxf.common.Version - License check failed for Orbeon Forms @RELEASE@ PE
2010-04-27 23:29:48,799 INFO org.orbeon.oxf.common.Version - Did not find PE Version, using CE Version
2010-04-27 23:29:49,214 WARN org.orbeon.oxf.xforms.processor.XFormsServer - ignoring property on xforms:model element {name: "computed-binds"}
2010-04-27 23:29:49,626 WARN org.orbeon.oxf.common.Version - Feature is not enabled in this version of the product: cached XForms instance
2010-04-27 23:29:49,747 WARN org.orbeon.oxf.xforms.processor.XFormsServer - xxforms:instanc
<?xml version="1.0" encoding="UTF-8"?>
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude">
<!-- Unroll the form (theme, components, inclusions) -->
@lacco
lacco / tribute.rb
Created February 24, 2010 00:25 — forked from burke/tribute.rb
def dsl &b
Class.new{
def r&b;instance_exec &b
end; def method_missing s,*_
@m=[s,*@m];end}.new.r &b
## Heckle for Rails
# Calls heckle for each method of each model
# Idea: Instead of exluding ActiveRecord methods, grep model file for existing methods
# Load all models
Dir['app/models/**/*.rb'].each {|f| require_dependency f}
# Search all model classes
klasses_to_heckle = ActiveRecord::Base.send(:subclasses)-[ActiveRecord::SessionStore::Session]
/**
* Registering callbacks on property setters.
*/
for(var prop in object){
// Ignore functions
if(typeof object[prop] !== 'function'){
(function(obj, attr) {
// If object does not already have a getter
if (!object.__lookupGetter__(prop)) {
// This variable will hold the value of the property
require 'factory_girl'
Dir["spec/factories/*"].each{|f| require f}
Factory.create :product
#=> new product with id=12
Product.first.update_versioned(:charge_interval => 'daily')
#=> new product with id=13
Product.all(:conditions => "id IN (select id from abstract_products group by name, edition having max(version))")
#=> Finds 12 instead of 13
Product.all(:conditions => 'version = (SELECT MAX(version) FROM abstract_products AS inner_abstract_products WHERE inner_abstract_products.name = abstract_products.name)')
#=> Finds 13 correctly
kschlichting@debian:/home/jmueller/.cruise/projects/ticketsystem/work$ sudo rake gems:install
(in /home/jmueller/.cruise/projects/ticketsystem/work)
kschlichting@debian:/home/jmueller/.cruise/projects/ticketsystem/work$ sudo gem list
*** LOCAL GEMS ***
actionmailer (2.3.4, 2.3.3, 2.3.2)
actionpack (2.3.4, 2.3.3, 2.3.2)
activerecord (2.3.4, 2.3.3, 2.3.2)
activeresource (2.3.4, 2.3.3, 2.3.2)
>> HistoryItem.new(:historytype => "Foo").valid?
Foo
[]
=> true
>> HistoryItem.new(:historytype => "Foo").valid?
Blub
["Foo"]
=> true