Skip to content

Instantly share code, notes, and snippets.

View dnch's full-sized avatar

Dan Cheail dnch

  • melbourne, au
View GitHub Profile
@dnch
dnch / gist:5241
Created August 13, 2008 15:21 — forked from nfelsen/gist:5197
<% @sections.each do |section| %>
<h2><%= section_name(section) %></h2>
<% section.topics.each do |topic| %>
<%= topic.name %><br>
<% end %>
<% end %>
ActionController::MethodNotAllowed (Only get and post requests are allowed.):
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/recognition_optimisation.rb:65:in `recognize_path'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/route_set.rb:384:in `recognize'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:148:in `handle_request'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:107:in `dispatch'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:104:in `synchronize'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:104:in `dispatch'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:35:in `dispatch'
/Library/Ruby/Gems/1.8/gems/passenger-2.0.3/lib/passenger/rail
def normalise_duration(duration_string)
seconds, minutes, hours = duration_string.split(/[:.]/).reverse.map(&:to_i)
# the extra to_i handles a nice case where nil.to_i == 0
seconds + (minutes.to_i * 60) + (hours.to_i * 3600)
end
class Foo < ActiveRecord::Base
end
result_set = Foo.find_calculations(:conditions => ["active = ?", true]) do
sum :field_one, :as => "sum_of_field_one"
count :field_four
max :field_one
min :field_one
mean :field_eight
end
## application.js
trigger_visibility_callbacks = function() {
$$(".conditional").each(function(e) {
eval(e.id + "_callback")
});
}
## view.html.erb
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.1/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant ActiveRecord::Validations (NameError)
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.1/lib/active_support/dependencies.rb:80:in `const_missing'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.1/lib/active_record/base.rb:3140
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.1/lib/active_record/base.rb:3138:in `class_eval'
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.1/lib/active_record/base.rb:3138
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.1/lib/active_record/validations.rb:9
from ./lib/money_handler.rb:19:in `enable'
from ./lib/money_handler.rb:26
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
... 10 levels...
def donate
@heroPage = HeroPage.search_url(params[:url], DateTime.now)
unless @heroPage
redirect_to :action=>"the_unknown_hero"
return
else
@donation = Donation.new()
# if @donation.save? then session[:mydonation_id] = @donation.id end
def self.determine_if_this_is_an_event_or_hero_page_mode(args)
if args[:event_url]
"event"
elsif args[:url]
"hero_page"
end
end
def self.retrieve_capture_fields(the_page, type_of_capture)
case the_page
when Event then retrieve_capture_data(type_of_capture, the_event_or_hero_page)
when HeroPage then
if the_event_or_hero_page.is_this_hero_page_associated_with_an_event && the_page.event
retrieve_capture_data(type_of_capture, the_page.event)
end
end
end
namespace :db do
desc "Migrate database from MySQL to PostgreSQL"
task :translate => :environment do
# how many are we going to do at a time (ie, how many per file?)
BATCH_SIZE = 10_000
# what tables are we dumping?
$tables_to_ignore = ['schema_migrations', 'sessions']
$tables_to_dump = ActiveRecord::Base.connection.tables.sort - $tables_to_ignore