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 ApplicationHelper | |
| def e_tag(model) | |
| eval("link_to image_tag(\'pencil.png\'), edit_#{model.class.name.underscore}_path(model)") | |
| end | |
| def d_tag(model) | |
| eval("link_to image_tag(\'delete.png\'), model, :confirm => \'Are you sure?\', :method => :delete") | |
| 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
| module DeepHash | |
| def deep_value(key_array) | |
| value = self | |
| Array(key_array).each do |key| | |
| value = value.fetch(key, nil) | |
| end | |
| value | |
| rescue NoMethodError | |
| nil |
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 ActionMailer | |
| class Base | |
| class_inheritable_accessor :view_paths | |
| def self.prepend_view_path(path) | |
| view_paths.unshift(*path) | |
| ActionView::TemplateFinder.process_view_paths(path) | |
| end | |
| def self.append_view_path(path) |
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
| # example <a onclick="popup('http://gooogle.com','Google',400,300);">Popup</a> | |
| function popup(link,title,width,height) { | |
| return window.open(link,title,"height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no"); | |
| } |
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
| [10:29 AM:n41(master)] $ ./script/console | |
| Loading development environment (Rails 2.1.1) | |
| >> m1, m2 = Money.new(200), Money.new(200) | |
| => [#<Money:0x32165f8 @currency="USD", @cents=200>, #<Money:0x32165e4 @currency="USD", @cents=200>] | |
| >> m2.eql?(m1) | |
| => true | |
| >> m1.eql?(m2) | |
| => true | |
| >> m1 == m2 | |
| => true |
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
| TherapistReport.send(:with_exclusive_scope) { | |
| @last_tr = TherapistReport.find(:all, :conditions => ["report_id = ? AND therapist_id = ? AND report.territory_id = ? ", self.report.previous, self.therapist_id, self.report.territory_id], :include => [:report]) | |
| } |
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 TrueClass | |
| def to_s | |
| "so fucking true" | |
| 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
| def truncate_words(text, length = 30, truncate_string = "..." ) | |
| return if text.nil? | |
| words = text.split | |
| words.length > length ? words[0...length].join(" ") + truncate_string : text | |
| 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
| desc "Download a tarball from Github and extract to a shared dir then symlink to vendor/rails" | |
| task :deploy_edge do | |
| puts "Pulling Rails from github" | |
| shared = ENV['SHARED_PATH'] || File.join('..','..','shared') | |
| shared_path = File.expand_path(shared) | |
| puts "Shared Path: #{shared_path}" | |
| rails_path = File.join(shared_path, 'rails') | |
| rails_version = ENV['VERSION'] || ENV['REVISION'] || 'v2.1.0' | |
| export_path = File.join(rails_path, "rails_#{rails_version}") |
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
| export PS1='\[\e[36;1m\][\@:\[\e[32;1m\]\W\[\e[33;1m\]$(__git_ps1 "(%s)")\[\e[32;1m\]] \[\e[0m\]$ ' | |
| # Color Code | |
| # Black 0;30 | |
| # Blue 0;34 | |
| # Green 0;32 | |
| # Cyan 0;36 | |
| # Red 0;31 | |
| # Purple 0;35 | |
| # Brown 0;33 |
OlderNewer