This file contains 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
# converts the number to a truncated number | |
# typically used for display of currency values | |
def smart_truncate(num) | |
return '--' if num.nil? | |
display_val = case | |
when num.abs > 999999: # 999,999 - round to 'X.YY M' | |
"%.#{2}f M" % (num / 1000000) | |
when num.abs > 999: # 999 - round to an integer | |
number_with_delimiter(number_with_precision(num, 0)) |
This file contains 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
/* | |
* Scale all textareas dynamically on the page | |
* Requires Prototype | |
*/ | |
Event.observe(window, 'load', function() { | |
$$('textarea').each(function(t){ | |
t.scale = function (){ | |
this.style.height = $F(this).split('\n').size() + 8 + "em"; | |
setTimeout(function(thisObj){ thisObj.scale(); }, 1000, this); | |
}; |
This file contains 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
# for examples of use, see... | |
# http://www.igvita.com/2007/03/15/block-helpers-and-dry-views-in-rails/ | |
def block_to_partial(partial_name, options = {}, &block) | |
options.merge!(:body => capture(&block)) | |
concat(render(:partial => partial_name, :locals => options), block.binding) | |
end | |
This file contains 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 seed fixtures (from db/fixtures) into the current environment's database." | |
task :seed => :environment do | |
require 'active_record/fixtures' | |
Dir.glob(RAILS_ROOT + '/db/fixtures/*.yml').each do |file| | |
Fixtures.create_fixtures('db/fixtures', File.basename(file, '.*')) | |
end | |
end | |
end |
This file contains 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
Omniauth Facebook Error - Faraday::Error::ConnectionFailed | |
Faraday::Error::ConnectionFailed | |
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed | |
Rails.application.config.middleware.use OmniAuth::Builder do | |
provider :facebook, '<key from fb>', '<another key from fb>' | |
end | |
class SessionsController < ApplicationController | |
def create |
This file contains 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
function constructor(init) { | |
var that = other_constructor(init), | |
member, | |
method = function () { | |
// init, member, method | |
}; | |
that_method = method; | |
This file contains 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
# app > controllers > concerns > convert_date_select_params.rb | |
module ConvertDateSelectParams | |
extend ActiveSupport::Concern | |
included do | |
before_action :convert_date | |
end | |
protected |
This file contains 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
Rails 6 | |
Sprockets::Rails::Helper::AssetNotPrecompiled in <new engine> | |
add //= link <new_engine>/application.css in the app/assets/config/manifest.js and restart the server |