Created
January 20, 2015 10:20
-
-
Save baothi/eca2f7fa7aa7c5c63e63 to your computer and use it in GitHub Desktop.
rake db:migrate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './lib/photo_associations' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load the Rails application. | |
require File.expand_path('../application', __FILE__) | |
# Initialize the Rails application. | |
Qjnavi::Application.initialize! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)