Skip to content

Instantly share code, notes, and snippets.

@benlieb
Last active December 29, 2015 01:29
Show Gist options
  • Save benlieb/7593002 to your computer and use it in GitHub Desktop.
Save benlieb/7593002 to your computer and use it in GitHub Desktop.
>> Page.first.active_children
ArgumentError: wrong number of arguments (2 for 1)
from /Users/benlieb/.rvm/gems/ruby-1.8.6-p420@csee_2.3.11/gems/activerecord-2.3.11/lib/active_record/associations/association_proxy.rb:174:in `sanitize_sql'
from /Users/benlieb/.rvm/gems/ruby-1.8.6-p420@csee_2.3.11/gems/activerecord-2.3.11/lib/active_record/associations/association_proxy.rb:174:in `send'
from /Users/benlieb/.rvm/gems/ruby-1.8.6-p420@csee_2.3.11/gems/activerecord-2.3.11/lib/active_record/associations/association_proxy.rb:174:in `sanitize_sql'
from /Users/benlieb/.rvm/gems/ruby-1.8.6-p420@csee_2.3.11/gems/activerecord-2.3.11/lib/active_record/associations/association_collection.rb:41:in `find'
from /Users/benlieb/.rvm/gems/ruby-1.8.6-p420@csee_2.3.11/gems/activerecord-2.3.11/lib/active_record/associations/association_collection.rb:423:in `find_target'
from /Users/benlieb/.rvm/gems/ruby-1.8.6-p420@csee_2.3.11/gems/activerecord-2.3.11/lib/active_record/associations/association_collection.rb:365:in `load_target'
from /Users/benlieb/.rvm/gems/ruby-1.8.6-p420@csee_2.3.11/gems/activerecord-2.3.11/lib/active_record/associations/association_proxy.rb:140:in `inspect'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:302:in `output_value'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:151:in `eval_input'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:263:in `signal_status'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:147:in `eval_input'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:146:in `eval_input'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:70:in `start'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:69:in `catch'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:69:in `start'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/bin/irb:17
>> Page.first.children
ArgumentError: wrong number of arguments (2 for 1)
from /Users/benlieb/.rvm/gems/ruby-1.8.6-p420@csee_2.3.11/gems/activerecord-2.3.11/lib/active_record/associations/association_proxy.rb:174:in `sanitize_sql'
from /Users/benlieb/.rvm/gems/ruby-1.8.6-p420@csee_2.3.11/gems/activerecord-2.3.11/lib/active_record/associations/association_proxy.rb:174:in `send'
from /Users/benlieb/.rvm/gems/ruby-1.8.6-p420@csee_2.3.11/gems/activerecord-2.3.11/lib/active_record/associations/association_proxy.rb:174:in `sanitize_sql'
from /Users/benlieb/.rvm/gems/ruby-1.8.6-p420@csee_2.3.11/gems/activerecord-2.3.11/lib/active_record/associations/association_collection.rb:41:in `find'
from /Users/benlieb/.rvm/gems/ruby-1.8.6-p420@csee_2.3.11/gems/activerecord-2.3.11/lib/active_record/associations/association_collection.rb:423:in `find_target'
from /Users/benlieb/.rvm/gems/ruby-1.8.6-p420@csee_2.3.11/gems/activerecord-2.3.11/lib/active_record/associations/association_collection.rb:365:in `load_target'
from /Users/benlieb/.rvm/gems/ruby-1.8.6-p420@csee_2.3.11/gems/activerecord-2.3.11/lib/active_record/associations/association_proxy.rb:140:in `inspect'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:302:in `output_value'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:151:in `eval_input'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:263:in `signal_status'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:147:in `eval_input'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:146:in `eval_input'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:70:in `start'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:69:in `catch'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/irb.rb:69:in `start'
from /Users/benlieb/.rvm/rubies/ruby-1.8.6-p420/bin/irb:17
source 'http://rubygems.org'
gem "rails", "2.3.14"
gem 'will_paginate', "2.3.16"
gem "money", "1.7.1"
gem "aasm", "0.0.2"
gem "hpricot", "0.6.0"
gem "webrat", "0.2.0"
gem "RedCloth", "4.0.1"
gem "awesome_print"
gem "fastercsv", "1.2.3"
#gem "mysql", "2.8.1"
gem "mysql2", "0.3.11"
gem "activerecord-mysql2-adapter"
gem "railsmachine"
gem 'rdoc', "2.5.11"
#bundler 0.9.24
#aasm (0.0.2)
#builder (2.1.2)
#cgi_multipart_eof_fix (2.5.0)
#daemons (1.0.10, 1.0.9)
#fastthread (1.0.1)
#gem_plugin (0.2.3)
#has_finder (0.1.5)
#hoe (1.7.0)
#rake (0.8.1)
#rubygems-update (1.2.0, 1.1.0)
# Ben's note 7.27.13
# These were needed on my local machine to get the app running
# I added them manually
#
# mysql2
# activerecord-mysql2-adapter
# capistrano
# railsmachine
# == Schema Information
# Schema version: 20080916502022
#
# Table name: pages
#
# id :integer(4) not null, primary key
# body :text
# sidebar :text
# created_at :datetime
# updated_at :datetime
# path :string(255)
# parent_id :integer(4)
# summary :text
# active :boolean(1) default(TRUE)
# display_child_page_summaries :boolean(1)
# title :string(255)
# shows_sidebar :boolean(1) default(TRUE)
#
class Page < ActiveRecord::Base
belongs_to :parent, :class_name => "Page"
has_many :children, :class_name => "Page", :foreign_key => "parent_id"
has_many :active_children, :class_name => "Page", :foreign_key => "parent_id", :conditions => {:active => true}
has_many :inactive_children, :class_name => "Page", :foreign_key => "parent_id", :conditions => {:active => false}
validates_uniqueness_of :title
validates_presence_of :title
validates_uniqueness_of :path
named_scope :parentable_for, lambda { |page|
if page.new_record?
excluded = []
else
excluded = page.children.collect(&:id) << page.id
end
if excluded.empty?
{:order => :title}
else
{:conditions => ["id NOT IN (?)", excluded], :order => :title}
end
}
def validate
if self.path.blank?
if parent.nil?
self.path = ""
else
self.path = parent.path.gsub(".html", "")
end
self.path = self.path + "/" + title.gsub(/\s/, "").underscore + ".html"
end
true
end
def pathmaps?
self.title == "Pathmaps"
end
def edit_form
# return "projects" if path == "/projects"
return "project" if parent and parent.path == "/projects"
"standard"
end
def layout
# return "projects" if path == "/projects"
# return "membership" if path == "/membership"
# return "about" if path == "/about"
"standard"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment