Public Gists by hardbap

Gravatar
Mon Jun 15 17:49:49 -0700 2009
1
2
3
# Three things to add:
# * before_filter call
# * action_has_layout? method (if you have one, combine them)
Gravatar
Mon Jun 15 08:30:41 -0700 2009
1
2
3
 @headers, @data = FasterCSV.parse(@current_user.uploads.last.attachment.path, :skip_blanks => true,
                                                                  :headers => true)
     @data.each do |row|
Gravatar
Wed Jun 03 14:38:26 -0700 2009
1
You may be asking yourself "why didn't this idiot just use [Sphinx](http://github.com/freelancing-god/thinking-sphinx, "thinking_sphinx"), [Xapian](http://github.com/frabcus/acts_as_xapian, "acts_as_xapian") or [Hyper Estraier](http://github.com/scoop/acts_as_searchable "acts_as_searchable")?". The
Gravatar
Sun May 17 16:12:13 -0700 2009
1
2
3
# check out Authlogic::Session::Password::Config
class User < ActiveRecord::Base
  acts_as_authentic do |config|
Gravatar
Fri May 08 04:53:53 -0700 2009
1
2
3
*** LOCAL GEMS ***
 
rails (2.3.2, 2.2.2, 2.1.2, 2.1.1, 2.1.0, 2.0.2, 2.0.1, 1.2.6, 1.2.5, 1.2.3)
Gravatar
Thu May 07 17:37:04 -0700 2009
1
2
3
class UserSessionsController < ApplicationController
  before_filter :require_user, :only => :destroy
  
Gravatar
Thu May 07 17:35:52 -0700 2009
1
2
3
class ApplicationController < ActionController::Base
  helper :all
  protect_from_forgery
Gravatar
Thu May 07 17:33:35 -0700 2009
1
2
3
require 'test_helper'
 
class UserSessionsControllerTest < ActionController::TestCase
Gravatar
Thu Apr 30 06:54:29 -0700 2009
1
2
3
// this is broken in IE. prevents the form from being submitted
$('.disableOnClick').bind('click', function(event) {
    $(this).attr('disabled', 'disabled').val("Please wait...");
Gravatar
Wed Apr 29 07:10:34 -0700 2009
1
2
3
class Test::Unit::TestCase
  def self.should_sum_total_ratings
    klass = model_class
Gravatar
Mon Apr 13 14:32:07 -0700 2009
1
2
3
class CreatePosts < ActiveRecord::Migration
  def self.up
    create_table :posts do |t|
Gravatar
Sat Apr 11 18:59:56 -0700 2009
1
2
3
      # Mailer.deliver_fancast_censored takes an argument, but shouldn't need to stub the arg...
      stub(Mailer).deliver_fancast_censored
 
Gravatar
Wed Apr 08 21:20:40 -0700 2009
1
2
3
class Order < ActiveRecord::Base
  attr_protected :state
end
Gravatar
Fri Mar 27 10:56:24 -0700 2009
1
2
3
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
gist: 86726 #count vs. #length or #size
Gravatar
Fri Mar 27 07:56:28 -0700 2009
1
2
3
demo[dev]>> b = Blog.last
=> #<Blog id: 4, title: "Blog Only", created_at: "2009-03-21 00:08:27", updated_at: "2009-03-21 00:08:27">
demo[dev]>> b.posts
Gravatar
Tue Mar 24 09:52:34 -0700 2009
1
2
3
def option_groups_from_collection_for_select_with_prompt(collection, group_method, group_label_method, option_key_method, option_value_method, selected_key = nil, prompt = 'Please choose')
  prompt_optgroup = "<optgroup label=\"\"><option value=\"\" selected=\"true\">#{prompt}</option></optgroup>"
    
Gravatar
Mon Mar 23 07:23:58 -0700 2009
1
2
3
# Ensure that the model accepts nested attributes for association
#
# Example:
Gravatar
Sat Mar 21 13:11:22 -0700 2009
1
2
3
  RAILS_GEM_VERSION = '2.3.0' unless defined? RAILS_GEM_VERSION
 
  # Bootstrap the Rails environment, frameworks, and default configuration
gist: 82960 a simple hack to use gists ...
Gravatar
Sat Mar 21 13:03:22 -0700 2009
1
2
3
# SUPER DARING APP TEMPLATE 1.0
# Originally By Peter Cooper
# Modified by Jason Seifer
Gravatar
Sat Mar 21 09:24:08 -0700 2009
1
2
3
demo[dev]>> b = Blog.last
=> #<Blog id: 4, title: "Blog Only", created_at: "2009-03-21 00:08:27", updated_at: "2009-03-21 00:08:27">
demo[dev]>> b.posts