Skip to content

Instantly share code, notes, and snippets.

@baothi
Created January 20, 2015 10:20
Show Gist options
  • Save baothi/eca2f7fa7aa7c5c63e63 to your computer and use it in GitHub Desktop.
Save baothi/eca2f7fa7aa7c5c63e63 to your computer and use it in GitHub Desktop.
rake db:migrate
require './lib/photo_associations'
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Qjnavi::Application.initialize!
rake db:migrate
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
rake aborted!
NoMethodError: private method `include' called for ActiveRecord::Base:Class
/home/thinb/rqjn/lib/photo_associations.rb:15:in `<top (required)>'
/home/thinb/rqjn/config/initializers/dependencies.rb:1:in `<top (required)>'
/home/thinb/rqjn/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
module PhotoAssociations
extend ActiveSupport::Concern
module ClassMethods
def has_many_photos(name)
has_many name, -> { where(kind: name.to_s) }, { as: :photoable, class_name: 'Photo' }
end
def has_one_photo(name)
has_one name, -> { where(kind: name.to_s).order('id desc') }, { as: :photoable, class_name: 'Photo' }
end
end
end
ActiveRecord::Base.include(PhotoAssociations)
@baothi
Copy link
Author

baothi commented Jan 21, 2015

rake db:migrate
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
rake aborted!
Dalli::RingError: No server available
/home/thinb/rqjn/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment