Skip to content

Instantly share code, notes, and snippets.

@jason
jason / gist:5073930
Created March 3, 2013 00:36
VoteTypes.name holds whether the vote is an aye, nay, or abstain. @ resolution has Resolution.find(params[:id}). Votes has the vote_type_id, the member_id (who it is that's voting) and the resolution_id
td = @vote_types[@resolution.votes.where(:member_id => n).first.vote_type_id - 1].name
@jason
jason / w1d4
Last active December 11, 2015 00:08 — forked from seanwooj/ w1d4
Hangman and Mastermind
@jason
jason / w1d4
Created January 11, 2013 21:19 — forked from nramadas/ w1d4
Hangman and Mastermind
@jason
jason / gist:3102148
Created July 13, 2012 01:17
rails console puking...
➜ rwsampleapp rails c
Loading development environment (Rails 3.2.6)
[1] pry(main)> require "capybara/rails"
=> true
[2] pry(main)> require "capybara_minitest_spec"
=> false
[3] pry(main)> require "minitest/autorun"
=> true
[4] pry(main)> include Rails.application.routes.url_helpers
=> Object
@jason
jason / gist:3090943
Created July 11, 2012 14:56
Not loading form_for inside of rails console? Also might be reason why my test is failing
➜ sample_app git:(sign-up) ✗ rails c
Loading development environment (Rails 3.2.6)
irb(main):001:0> require "capybara/rails"
=> true
irb(main):002:0> include Capybara::DSL
=> Object
irb(main):003:0> include Rails.application.routes.url_helpers
=> Object
irb(main):005:0> visit signup_path
=> nil
require "rubygems"
require "google_spreadsheet"
# Logs in.
# You can also use OAuth. See document of GoogleSpreadsheet.login_with_oauth for details.
session = GoogleSpreadsheet.login(login, password)
# First worksheet of http://spreadsheets.google.com/ccc?key=pz7XtlQC-PYx-jrVMJErTcg&hl=en
ws = session.spreadsheet_by_key(dockey).worksheets[0]
require "rubygems"
require "google_spreadsheet"
# Logs in.
# You can also use OAuth. See document of GoogleSpreadsheet.login_with_oauth for details.
session = GoogleSpreadsheet.login(login, password)
# First worksheet of http://spreadsheets.google.com/ccc?key=pz7XtlQC-PYx-jrVMJErTcg&hl=en
ws = session.spreadsheet_by_key(dockey).worksheets[0]
#puts ws.rows[1]
# Helper methods defined here can be accessed in any controller or view in the application
Emparse.helpers do
def logindata(login, password, spreadkey)
session = GoogleSpreadsheet.login(login, password)
ws = session.spreadsheet_by_key(spreadkey).worksheets[0]
fname = []
lname = []
address = []
for row in 2..ws.num_rows
[root@dev /var/www/jasonwong]# script/console RAILS_ENV=production
Loading RAILS_ENV=production environment (Rails 2.2.2)
/opt/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:340:in `read':Errno::ENOENT: No such file or directory - /var/www/jasonwong/config/environments/RAILS_ENV=production.rb
/var/www/jasonwong/app/controllers/application.rb:9:NoMethodError: undefined method `auto_include!' for ApplicationController:Class
>> Asset
ActiveRecord::ConnectionNotEstablished: ActiveRecord::ConnectionNotEstablished
from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in `retrieve_connection'
from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:121:in `retrieve_connection'
from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:113:in `connectio
NoMethodError in Admin/overview#index
Showing admin/overview/_comment_event.rhtml where line #8 raised:
undefined method `-' for {:length=>100}:Hash
Extracted source (around line #8):
5:
6: <span class="event-time"><%= event_time_for event, later %></span>