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
# We use this chunk of controller code all over to generate PDF files. | |
# | |
# To stay DRY we placed it here instead of repeating it all over the place. | |
# | |
module PdfHelper | |
require 'prince' | |
private | |
# Makes a pdf, returns it as data... | |
def make_pdf(template_path, pdf_name, landscape=false) |
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
# Prince XML Ruby interface. | |
# http://www.princexml.com | |
# | |
# Library by Subimage Interactive - http://www.subimage.com | |
# | |
# | |
# USAGE | |
# ----------------------------------------------------------------------------- | |
# prince = Prince.new() | |
# html_string = render_to_string(:template => 'some_document') |
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
namespace :db do | |
desc "Load production data into development database" | |
task :load_production_data, :roles => :db, :only => { :primary => true } do | |
require 'yaml' | |
# Gets db yml from server, because we don't store it on dev boxes! | |
get "#{current_path}/config/database.yml", "tmp/prod_database.yml" | |
prod_config = YAML::load_file('tmp/prod_database.yml') | |
local_config = YAML::load_file('config/database.yml') | |
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
namespace :sync do | |
desc "Load production data into development database" | |
task :database, :roles => :db, :only => { :primary => true } do | |
require 'yaml' | |
# Gets db yml from server, because we don't store it on dev boxes! | |
get "#{current_path}/config/database.yml", "tmp/prod_database.yml" | |
prod_config = YAML::load_file('tmp/prod_database.yml') | |
local_config = YAML::load_file('config/database.yml') |
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
// A sub-store implementation that allows you to store local | |
// cached records in a 'parentStore', and then use this to present | |
// a view you can filter on for DataViews like List, etc. | |
// | |
// Dynamically selects data from parentStore, and refreshes itself | |
// when data in that store is changed. | |
// | |
// Allows passing a queryFunc to restrict selection of records | |
// from the parentStore. | |
Ext.define('CbMobile.store.ChildView', { |
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
// The default TextAreaField in Sencha touch 2 is difficult to use | |
// on a mobile device. | |
// | |
// This when tapped to edit, this displays the text full screen, and allows | |
// for better reading and editing. | |
// | |
// Modified from 'BetterTextArea' | |
// http://colinramsay.co.uk/diary/2012/05/18/a-better-textareafield-for-sencha-touch-2/ | |
Ext.define('Ext.ux.field.FullScreenTextArea', { |
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
/* | |
Original Author : Mitchell Simoens | |
ST2 revision Author : Di Peng | |
ST2 revised revision by: [email protected] | |
Purpose : Creation of a custom color picker | |
License : GPL v3 (http://www.gnu.org/licenses/gpl.html) | |
Warranty : none | |
Price : free |
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
// Extended model that fires events on CRUD actions, | |
// and allows for reloading of data from the server. | |
Ext.define('CbMobile.model.Base', { | |
extend: 'Ext.data.Model', | |
// Overloaded methods that fire events | |
set: function(fieldName, value) { | |
this.callParent(arguments); | |
this.fireEvent('set', fieldName, value); | |
}, |
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
# If you have a large test suite, being able to test only a subset | |
# of those items is a big speed boost. | |
# | |
# With this in your .autotest file you can run "autotest /some/dir" and only test | |
# the files within. | |
# | |
require 'redgreen/autotest' | |
Autotest.add_hook :initialize do |at| | |
unless ARGV.empty? |
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
# Projects a user has access to either through ProjectAssignment, or as an "account manager" | |
named_scope :user_has_access_to, lambda{|user| | |
{ | |
:select => 'DISTINCT projects.*', | |
:joins => %q\ | |
LEFT JOIN project_assignments | |
ON ( | |
projects.id = project_assignments.project_id | |
AND project_assignments.has_access = 1 | |
) |