From 642e5ab45b1a011ac0ad6ff63f4786e2c2d51d30 Mon Sep 17 00:00:00 2001 From: jaideng123 Date: Sat, 6 Sep 2014 14:44:54 -0500 Subject: [PATCH] Fixed Open Graph db insertion --- app/models/open_graph_cache.rb | 2 +- db/migrate/20140906192846_fix_open_graph_data.rb | 10 ++++++++++ db/schema.rb | 8 ++++---- 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20140906192846_fix_open_graph_data.rb diff --git a/app/models/open_graph_cache.rb b/app/models/open_graph_cache.rb index 8c6e32841..d0c94362e 100644 --- a/app/models/open_graph_cache.rb +++ b/app/models/open_graph_cache.rb @@ -26,7 +26,7 @@ class OpenGraphCache < ActiveRecord::Base return if response.blank? || response.type.blank? - self.title = response.title + self.title = response.title.truncate(255) self.ob_type = response.type self.image = response.images[0] self.url = response.url diff --git a/db/migrate/20140906192846_fix_open_graph_data.rb b/db/migrate/20140906192846_fix_open_graph_data.rb new file mode 100644 index 000000000..54959931d --- /dev/null +++ b/db/migrate/20140906192846_fix_open_graph_data.rb @@ -0,0 +1,10 @@ +class FixOpenGraphData < ActiveRecord::Migration + def self.up + change_column :open_graph_caches, :url, :text + change_column :open_graph_caches, :image, :text + end + def self.down + change_column :open_graph_caches, :url, :string + change_column :open_graph_caches, :image, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index aa8406d86..80202933c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140826165533) do +ActiveRecord::Schema.define(version: 20140906192846) do create_table "account_deletions", force: true do |t| t.string "diaspora_handle" @@ -219,8 +219,8 @@ ActiveRecord::Schema.define(version: 20140826165533) do create_table "open_graph_caches", force: true do |t| t.string "title" t.string "ob_type" - t.string "image" - t.string "url" + t.text "image" + t.text "url" t.text "description" end @@ -570,4 +570,4 @@ ActiveRecord::Schema.define(version: 20140826165533) do add_foreign_key "share_visibilities", "contacts", name: "post_visibilities_contact_id_fk", dependent: :delete -end +end \ No newline at end of file