View application.js
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
// Place your application-specific JavaScript functions and classes here | |
// This file is automatically included by javascript_include_tag :defaults | |
// Thanks to http://henrik.nyh.se/2008/05/rails-authenticity-token-with-jquery for the ajaxSend advice | |
// Adds the authenticity token to each request when needed - used in conjunction with | |
// <%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %> | |
$(document).ajaxSend(function(event,request,settings){ | |
if (typeof(AUTH_TOKEN) == "undefined") return; | |
settings.data = settings.data || ""; |
View gist:114062
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
module ActionView::Helpers::TextHelper | |
def truncate(text, *args) | |
options = args.extract_options! | |
# support either old or Rails 2.2 calling convention: | |
unless args.empty? | |
options[:length] = args[0] || 30 | |
options[:omission] = args[1] || "..." | |
end | |
options.reverse_merge!(:length => 30, :omission => "...") |
View gist:211700
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
module ScopedTags | |
module ActiveRecordAdditions | |
def self.included(base) | |
base.class_eval do | |
def self.scoped_tags(contexts, options = nil) | |
cattr_accessor :tag_contexts | |
raise ScopedTagsError, 'context is required for scoped-tags setup' if contexts.blank? |
View selenium_steps.rb
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
Then /^I should see "([^\"]*)" in "([^\"]*)"$/ do |text, selector| | |
response_body.should have_tag(selector, /#{Regexp.escape(text)}/) | |
end |
View attr_test.rb
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
module Tom | |
class << self | |
attr_accessor :dick | |
end | |
end | |
Tom.dick = 'harry' |
View opacity.sass
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
/ This SASS function makes it easy to get cross-browser opacity. | |
/ | |
/ Firefox and Safari use CSS opacity. | |
/ Internet Explorer 7 and 8 each require their own flavor of the opacity alpha filter. | |
/ | |
/ See http://www.quirksmode.org/css/opacity.html for more info on opacity. | |
/ | |
/ Pass an opacity value between 0.0 and 1.0 | |
=opacity(!value) | |
:opacity= !value |
View deploy.rb
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 :deploy do | |
desc 'Bundle and minify the JS and CSS files' | |
task :precache_assets, :roles => :app do | |
root_path = File.expand_path(File.dirname(__FILE__) + '/..') | |
jammit_path = Dir["#{root_path}/vendor/gems/jammit-*/bin/jammit"].first | |
yui_lib_path = Dir["#{root_path}/vendor/gems/yui-compressor-*/lib"].first | |
assets_path = "#{root_path}/public/assets" | |
# Precaching assets | |
run_locally "ruby -I#{yui_lib_path} #{jammit_path}" |
View bundler_cap.rb
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 :bundler do | |
task :install, :roles => :app, :except => { :no_release => true } do | |
run("gem install bundler --source=http://gemcutter.org") | |
end | |
task :symlink_vendor, :roles => :app, :except => { :no_release => true } do | |
shared_gems = File.join(shared_path, 'vendor/gems/ruby/1.8') | |
release_gems = "#{release_path}/vendor/gems/ruby/1.8" | |
# if you don't commit your cache, add cache to this list | |
%w(gems specifications).each do |sub_dir| |
View authenticable.rb
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
def update_with_password(params={}) | |
current_password = params.delete(:current_password) | |
params.delete(:password) if params[:password].blank? | |
params.delete(:password_confirmation) if params[:password_confirmation].blank? | |
skip_password_check = !(current_password.present? || params[:password] || params[:password_confirmation]) | |
result = if skip_password_check || valid_password?(current_password) | |
update_attributes(params) |
View Gemfile
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
source :gemcutter | |
gem 'rails', '2.3.4', :require => nil | |
gem 'mysql' |
OlderNewer