From 9a3266b3e43b5914a8d69a39dc981f0d6277b727 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 24 Aug 2014 02:16:50 +0200 Subject: [PATCH] Added backward compatibility. --- app/models/recent_view.rb | 12 ++++++------ ...0001_update_recent_viewed_create_object_lookup.rb | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/models/recent_view.rb b/app/models/recent_view.rb index ee7de2c4e..f0b4f8d77 100644 --- a/app/models/recent_view.rb +++ b/app/models/recent_view.rb @@ -10,15 +10,15 @@ class RecentView < ApplicationModel # create entry record = { - :o_id => o_id, - :object_lookup_id => object_lookup_id.to_i, - :created_by_id => user.id, + :o_id => o_id, + :recent_view_object_id => object_lookup_id.to_i, + :created_by_id => user.id, } RecentView.create(record) end def self.log_destroy( requested_object, requested_object_id ) - RecentView.where( :object_lookup_id => ObjectLookup.by_name( requested_object ) ). + RecentView.where( :recent_view_object_id => ObjectLookup.by_name( requested_object ) ). where( :o_id => requested_object_id ). destroy_all end @@ -35,8 +35,8 @@ class RecentView < ApplicationModel list = [] recent_views.each { |item| data = item.attributes - data['object'] = ObjectLookup.by_id( data['object_lookup_id'] ) - data.delete( 'object_lookup_id' ) + data['object'] = ObjectLookup.by_id( data['recent_view_object_id'] ) + data.delete( 'recent_view_object_id' ) list.push data } list diff --git a/db/migrate/20140823000001_update_recent_viewed_create_object_lookup.rb b/db/migrate/20140823000001_update_recent_viewed_create_object_lookup.rb index 8d3e043ad..3e40cb87e 100644 --- a/db/migrate/20140823000001_update_recent_viewed_create_object_lookup.rb +++ b/db/migrate/20140823000001_update_recent_viewed_create_object_lookup.rb @@ -15,9 +15,7 @@ class UpdateRecentViewedCreateObjectLookup < ActiveRecord::Migration entry.cache_delete } - rename_column :recent_views, :recent_view_object_id, :object_lookup_id drop_table :recent_view_objects - Cache.clear end