Commit 71b019f0358362f2d4ef2dca1af3f5e17300bcc9
1 parent
eb8d2df0
Exists in
master
and in
11 other branches
rails4: put default primary key and convert Rails.root.join for gsub
Showing
3 changed files
with
7 additions
and
2 deletions
Show diff stats
lib/noosfero/core_ext/active_record.rb
| ... | ... | @@ -2,6 +2,11 @@ require 'active_record' |
| 2 | 2 | |
| 3 | 3 | class ActiveRecord::Base |
| 4 | 4 | |
| 5 | + # default primary key | |
| 6 | + def self.primary_key | |
| 7 | + @primary_key = 'id' if self.column_names.include? 'id' | |
| 8 | + end | |
| 9 | + | |
| 5 | 10 | def self.postgresql? |
| 6 | 11 | ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' |
| 7 | 12 | end | ... | ... |
lib/noosfero/plugin.rb
| ... | ... | @@ -149,7 +149,7 @@ class Noosfero::Plugin |
| 149 | 149 | |
| 150 | 150 | def load_plugin_extensions(dir) |
| 151 | 151 | ActionDispatch::Reloader.to_prepare do |
| 152 | - Dir[File.join(dir, 'lib', 'ext', '*.rb')].each {|file| require_dependency file } | |
| 152 | + Dir[File.join(dir, 'lib', 'ext', '*.rb')].each{ |file| require_dependency file } | |
| 153 | 153 | end |
| 154 | 154 | end |
| 155 | 155 | ... | ... |
lib/postgresql_attachment_fu.rb
| ... | ... | @@ -10,7 +10,7 @@ module PostgresqlAttachmentFu |
| 10 | 10 | def full_filename(thumbnail = nil) |
| 11 | 11 | file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s |
| 12 | 12 | file_system_path = File.join(file_system_path, ActiveRecord::Base.connection.schema_search_path) if ActiveRecord::Base.postgresql? and Noosfero::MultiTenancy.on? |
| 13 | - Rails.root.join(file_system_path, *partitioned_path(thumbnail_name_for(thumbnail))) | |
| 13 | + Rails.root.join(file_system_path, *partitioned_path(thumbnail_name_for(thumbnail))).to_s | |
| 14 | 14 | end |
| 15 | 15 | end |
| 16 | 16 | ... | ... |