From 71b019f0358362f2d4ef2dca1af3f5e17300bcc9 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Mon, 13 Jul 2015 15:23:34 -0300 Subject: [PATCH] rails4: put default primary key and convert Rails.root.join for gsub --- lib/noosfero/core_ext/active_record.rb | 5 +++++ lib/noosfero/plugin.rb | 2 +- lib/postgresql_attachment_fu.rb | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/noosfero/core_ext/active_record.rb b/lib/noosfero/core_ext/active_record.rb index 63fff73..f319270 100644 --- a/lib/noosfero/core_ext/active_record.rb +++ b/lib/noosfero/core_ext/active_record.rb @@ -2,6 +2,11 @@ require 'active_record' class ActiveRecord::Base + # default primary key + def self.primary_key + @primary_key = 'id' if self.column_names.include? 'id' + end + def self.postgresql? ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' end diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index ac12a34..7a880dd 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -149,7 +149,7 @@ class Noosfero::Plugin def load_plugin_extensions(dir) ActionDispatch::Reloader.to_prepare do - Dir[File.join(dir, 'lib', 'ext', '*.rb')].each {|file| require_dependency file } + Dir[File.join(dir, 'lib', 'ext', '*.rb')].each{ |file| require_dependency file } end end diff --git a/lib/postgresql_attachment_fu.rb b/lib/postgresql_attachment_fu.rb index dba629f..9d7ec6d 100644 --- a/lib/postgresql_attachment_fu.rb +++ b/lib/postgresql_attachment_fu.rb @@ -10,7 +10,7 @@ module PostgresqlAttachmentFu def full_filename(thumbnail = nil) file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s file_system_path = File.join(file_system_path, ActiveRecord::Base.connection.schema_search_path) if ActiveRecord::Base.postgresql? and Noosfero::MultiTenancy.on? - Rails.root.join(file_system_path, *partitioned_path(thumbnail_name_for(thumbnail))) + Rails.root.join(file_system_path, *partitioned_path(thumbnail_name_for(thumbnail))).to_s end end -- libgit2 0.21.2