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
<table cellpadding="0" cellspacing="0"> | |
<% | |
begin | |
remote_controller = active_scaffold_controller_for(column.association.klass).new | |
remote_request_env = {} | |
request.env.select {|key, value| key == key.upcase || key == 'rack.input'}.each {|item| remote_request_env[item[0]] = item[1]} | |
remote_request_env["warden"] = request.env["warden"] if (request.env.has_key?("warden")) | |
remote_request = ActionDispatch::Request.new(remote_request_env) |
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
<table cellpadding="0" cellspacing="0"> | |
<% @record = column.association.klass.new -%> | |
<% | |
case parent_record | |
when DocumentItem then @record.project_id = parent_record.management_process.project_id | |
when Project then @record.project_id = parent_record.project_id | |
end | |
%> | |
<%= render :partial => 'horizontal_subform_header', :locals => {:parent_record => parent_record} %> |
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
/* Copyright(C) by William Estrada Jul 16, 2008, All rights reserved * | |
* [email protected] */ | |
#define _GNU_SOURCE | |
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <sys/types.h> | |
#include <openssl/rsa.h> |
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
# is usually called with :crud_type and :column, or :action | |
# {:crud_type=>:update, :column=>"some_colum_name"} | |
# {:action=>"edit"} | |
# to allow access cancan must allow both :crud_type and :action | |
# if cancan says "no", it delegates to default AS behavior | |
def authorized_for_with_cancan?(options = {}) | |
raise InvalidArgument if options[:crud_type].blank? and options[:action].blank? | |
if current_ability.present? | |
crud_type_result = options[:crud_type].nil? ? true : current_ability.can?(options[:crud_type], self) | |
action_result = options[:action].nil? ? true : current_ability.can?(options[:action].to_sym, self) |
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
# monkey-patch https://github.com/ryanb/cancan/issues/327 | |
# put in Rails.root/config/initializers/cancan.rb | |
module CanCan | |
module ModelAdapters | |
class ActiveRecordAdapter | |
private | |
# fix nested imbrication | |
def merge_conditions(sql, conditions_hash, behavior) | |
if conditions_hash.blank? |
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 Base | |
@include: (module) -> | |
@::[k] = v for k, v of module:: | |
@has_many: (rel, opts) -> | |
@::[rel] = -> console.log rel | |
@tableName: -> | |
@_tableName ?= @toString().match(/function ([^\(]+)/)[1] | |
@find: (id) -> | |
console.log "SELECT * FROM #{@tableName()} WHERE id = #{id}" | |
save: (opts = null) -> |
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
# Behavior with state attached | |
func = do -> | |
variable = 0 # state | |
-> console.log variable++ # behavior | |
func() # 0 | |
func() # 1 | |
# State with behavior attached |
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
<%# custom view for reporting %> | |
<% | |
record = list_record_report if list_record_report # compat with render :partial :collection | |
columns ||= list_columns | |
tr_class = cycle("", "even-record") | |
tr_class += " #{list_row_class(record)}" if respond_to? :list_row_class | |
url_options = params_for(:action => :list, :id => record.id) | |
# TODO: refactor, pull to Volker |
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 'underscore' | |
includeCopy = (to, module) -> | |
proto = to:: | |
for name, property of module | |
proto[name] = property | |
includeInter = (to, module) -> | |
m = _.clone(module) | |
originalPrototype = to.prototype |
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
# stop the execution and open a debug console | |
import pdb; pdb.set_trace() | |
# inspect the object (what names it defines, as in methods) | |
dir(object) | |
# inspect the object more (the dictionary of attributes, as in properties) | |
dir(object.__dict__) # or something like that |