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 | |
| include FeedbackHelper | |
| # Your methods here | |
| 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
| # needed to fix prepared statements error in Rails 3.1 | |
| after_fork do | server, worker | | |
| ActiveRecord:: Base.connection.reconnect! | |
| 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
| # create this in helpers/feedback_helper.rb | |
| # use version 1 for haml (buggy) or version 2 for erb | |
| # version 1 via haml | |
| require 'haml' | |
| module FeedbackHelper | |
| def self.included(base) | |
| base.class_eval do | |
| include Haml::Helpers |
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
| set :rvm_ruby_string, '<interpreter>@<gemset>' | |
| # Load RVM's capistrano plugin. | |
| require "rvm/capistrano" | |
| set :rvm_path, "$HOME/.rvm" |
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
| # model code | |
| property :paths_mask, Integer | |
| NODE_PATH = %w(path_1 path_2 path_3 path_4) | |
| def paths=(paths) | |
| self.paths_mask = (paths & NODE_PATH).map { |r| 2**NODE_PATH.index(r) }.sum | |
| end | |
| def paths |
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 active_site_links | |
| # Possible memcache candidate | |
| c = %w{editions forms questions question_answers} | |
| h = c.inject({}) {|a,x| a[x.to_sym] = {:name => x}; a } | |
| if h.has_key? controller.controller_name.to_sym | |
| h[controller.controller_name.to_sym][:active] = true | |
| end | |
| h | |
| 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 Monkeys | |
| # Here there be monkeys! This is for english langauge. | |
| # essentially the regex doesn't titleize 1, 2, & 3 letter words | |
| # needs improvement IMO. Maybe an array of black list words. | |
| # eg. of an a the | |
| module ActiveSupport::Inflector | |
| def titleize(word) | |
| humanize(underscore(word)).gsub(/\b('?[a-z]{3})/) { $1.capitalize } |
NewerOlder