Created
January 4, 2017 01:46
-
-
Save jdblack/d8f1145052aeaf37334b4b754d75dc4f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
ActiveRecord::Schema.define(version: 20170104013645) do | |
create_table "comments", force: :cascade do |t| | |
t.integer "stars" | |
t.string "review" | |
t.datetime "created_at", null: false | |
t.datetime "updated_at", null: false | |
t.index [nil, nil], name: "index_comments_on_commentable_type_and_commentable_id" | |
end | |
create_table "shops", force: :cascade do |t| | |
t.datetime "created_at", null: false | |
t.datetime "updated_at", null: false | |
t.string "name" | |
end | |
create_table "sites", force: :cascade do |t| | |
t.datetime "created_at", null: false | |
t.datetime "updated_at", null: false | |
t.string "name" | |
end | |
end |
This file contains hidden or 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
~/code/objtest/db$ rails c | |
Running via Spring preloader in process 10981 | |
SLoading development environment (Rails 5.0.1) | |
2.3.0 :001 > Shop.all | |
Shop Load (5.6ms) SELECT "shops".* FROM "shops" | |
=> #<ActiveRecord::Relation [#<Shop id: 1, created_at: "2017-01-04 01:38:16", updated_at: "2017-01-04 01:38:16", name: "Bellvue Divers">]> | |
2.3.0 :002 > Site.all | |
Site Load (0.2ms) SELECT "sites".* FROM "sites" | |
=> #<ActiveRecord::Relation [#<Site id: 1, created_at: "2017-01-04 01:37:52", updated_at: "2017-01-04 01:38:35", name: "Alki Cove 2">]> | |
2.3.0 :003 > Comment.all | |
Comment Load (0.2ms) SELECT "comments".* FROM "comments" | |
=> #<ActiveRecord::Relation []> | |
2.3.0 :004 > Site.first.comments.all | |
Site Load (0.3ms) SELECT "sites".* FROM "sites" ORDER BY "sites"."id" ASC LIMIT ? [["LIMIT", 1]] | |
Comment Load (0.7ms) SELECT "comments".* FROM "comments" WHERE "comments"."commentable_id" = ? AND "comments"."commentable_type" = ? [["commentable_id", 1], ["commentable_type", "Site"]] | |
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: comments.commentable_id: SELECT "comments".* FROM "comments" WHERE "comments"."commentable_id" = ? AND "comments"."commentable_type" = ? | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.12/lib/sqlite3/database.rb:91:in `initialize' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.12/lib/sqlite3/database.rb:91:in `new' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/sqlite3-1.3.12/lib/sqlite3/database.rb:91:in `prepare' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:209:in `block in exec_query' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:589:in `block in log' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:583:in `log' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:193:in `exec_query' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:377:in `select_prepared' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:39:in `select_all' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract/query_cache.rb:95:in `select_all' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/querying.rb:39:in `find_by_sql' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/relation.rb:702:in `exec_queries' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/association_relation.rb:32:in `exec_queries' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/relation.rb:583:in `load' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activerecord-5.0.1/lib/active_record/relation.rb:260:in `records' | |
... 2 levels... | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands/console_helper.rb:9:in `start' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:78:in `console' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `block in require' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require' | |
from /Users/jblack/code/objtest/bin/rails:9:in `<top (required)>' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `block in load' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency' | |
from /Users/jblack/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load' | |
from /Users/jblack/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' | |
from /Users/jblack/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' | |
from -e:1:in `<main>'2.3.0 :005 > |
This file contains hidden or 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
class Comment < ApplicationRecord | |
belongs_to :commentable, polymorphic: true | |
end |
This file contains hidden or 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
class Shop < ApplicationRecord | |
has_many :comments, as: :commentable | |
end |
This file contains hidden or 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
class Site < ApplicationRecord | |
has_many :comments, as: :commentable | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment