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 'udt_model' | |
class MetaMark::ActiveRecordModel | |
extend UdtModel | |
def self.active_record_model_as_file(udt) | |
# return if File.exist?(udt.path_to_udt_model) | |
# m = MetaMark::ActiveRecordModel.new(udt) | |
table_name = udt.db_table_name | |
new_class_name = udt.udt_class_name # m.udt_class_name(table_name, udt) |
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 Udt < ActiveRecord::Base | |
include AASM | |
has_paper_trail | |
belongs_to :project | |
has_one :organization, through: :project | |
has_one :workflow, dependent: :destroy | |
has_many :workflow_scripts, as: :aasm_scriptable, dependent: :destroy, class_name: 'AasmScript' | |
has_many :udt_table_fields, -> { order(position: :asc) }, dependent: :destroy |
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
Why not to use has_many association extension over has_many with conditions! | |
Has many is useful for adding in new functionality to the has_many association, however the problem with these entensions is | |
that Rails doesn't cache them. So every time you call object.members.requested it makes a call to the database. | |
has_many :organization_users | |
has_many :members, through: :organization_users, source: :user | |
has_many :members, through: :organization_users, source: :user do | |
def requested |
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 :database_utilities do | |
desc "Recreate a sqlite3 dev db from current pg_dump from production." | |
# This task should only ever be run in a development environment. | |
task create_sqlite3_from_pg_dump: :environment do | |
# by Mark on Wed May 13 06:15:09 EDT 2015 | |
# Based on the ideals from this webpage: | |
# http://manuel.manuelles.nl/blog/2012/01/18/convert-postgresql-to-sqlite/ |
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
module ActiveScaffoldStateMachine | |
# add to controller | |
#config.action_links.member.add 'get_states', position: false | |
=begin | |
Then create a view called get_states.js.erb and put it in the view dir or | |
a common directory called active_scaffold_overrides which contains the following: | |
<% |
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 must have function for thinking sphinx, eg: | |
# | |
#Location.search("taco", :geo => [33.653275.to_radian, -117.646854.to_radian ], #:order => "@geodist ASC").map(&:address).map(&:city) | |
class Numeric | |
def to_radian | |
self * Math::PI / 180 | |
end | |
end |
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
#!/usr/bin/ruby1.8 | |
require 'tk' | |
require 'open3' | |
require 'net/telnet' | |
require 'fileutils' | |
require 'date' | |
DESTINATION_DIR = "/tmp" |
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
sudo apt-get install postgresql | |
l; | |
1003 sudo apt-get install libproj-dev libxml2-dev postgresql-server-dev-8.4 | |
1004 sudo apt-get install libproj-dev libxml2-dev postgresql-server-dev-8.4.4 | |
1005 sudo apt-get install libproj-dev libxml2-dev postgresql-server-dev-8.4 | |
1006 psql |
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
Hey Ben, | |
if you add in the ' -limit memory 1 -limit map 1 ' to your transformation_command method it causes imagemagick to use file space instead of memory space. Now I dont have to buy more ram and it does the same thing! | |
----------------------------------------------------------- | |
"papermill_paperclip_processor.rb" 82L, 3241C written | |
def transformation_command | |
" -limit memory 1 -limit map 1 #{(crop_command ? super.sub(/ -crop \S+/, crop_command) : super)} #{copyright_command} #{watermark_command}".sub(%{-resize "0x" }, "") |
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
module AasmAddons | |
def self.included(base_class) | |
base_class.class_eval do | |
def aasm_fire_event(*args) | |
line_items.each do |li| | |
#li.send("#{args.first.to_s}!") | |
li.update_attributes(:state => args.first.to_s) | |
end | |
state_logs.create!(:state => args.first.to_s, :user => current_user) | |
super(*args) |
NewerOlder