AutoCommit Mit Jun 17 13:03:07 CEST 2015
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -22,7 +22,7 @@ group :assets do
|
||||
gem 'therubyracer', :platforms => :ruby
|
||||
gem 'uglifier', '>= 1.0.3'
|
||||
end
|
||||
|
||||
gem 'active_record_query_trace'
|
||||
|
||||
gem 'jquery-rails'
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class Neuigkeit < ActiveRecord::Base
|
||||
has_many :nlinks, :dependent=> :destroy
|
||||
has_one :meeting
|
||||
has_many :attachments, :as=>:parent
|
||||
|
||||
has_one :title_pic, :class_name=>"Attachment", :as=>:parent, :conditions=>["attachments.flag_titlepic =?", true]
|
||||
|
||||
|
||||
validates :rubrik, :presence=>true
|
||||
@@ -29,7 +29,7 @@ class Neuigkeit < ActiveRecord::Base
|
||||
translates :title,:text, :versioning=>{:gem=>:paper_trail, :options=>{:fallbacks_for_empty_translations => true}}
|
||||
mount_uploader :picture, PictureUploader
|
||||
|
||||
default_scope order(:cache_order)
|
||||
default_scope order(:cache_order).includes(:calentries).includes(:title_pic)
|
||||
scope :recent, -> { published.limit(10)}
|
||||
scope :unpublished, -> {where("datum > ? OR datum IS NULL", Time.now)}
|
||||
scope :published_scope, ->{where("datum <= ? AND datum IS NOT NULL", Time.now)}
|
||||
@@ -66,8 +66,9 @@ class Neuigkeit < ActiveRecord::Base
|
||||
if self.has_meeting?
|
||||
return self.meeting.meetingtyp.picture
|
||||
else
|
||||
unless self.attachments.where(flag_titlepic: true).first.nil?
|
||||
return self.attachments.where(flag_titlepic: true).first.datei
|
||||
unless self.title_pic.nil?
|
||||
# return self.attachments.where(flag_titlepic: true).first.datei
|
||||
return self.title_pic.datei
|
||||
else
|
||||
return self.picture
|
||||
end
|
||||
|
||||
1
config/initializers/query_trace.rb
Normal file
1
config/initializers/query_trace.rb
Normal file
@@ -0,0 +1 @@
|
||||
ActiveRecordQueryTrace.enabled=true
|
||||
12
db/migrate/20150617105704_add_index_for_neuigkeiten.rb
Normal file
12
db/migrate/20150617105704_add_index_for_neuigkeiten.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class AddIndexForNeuigkeiten < ActiveRecord::Migration
|
||||
def up
|
||||
add_index :neuigkeiten, :rubrik_id
|
||||
add_index :calentries, [:object_type, :object_id]
|
||||
add_index :attachments, [:parent_type, :parent_id]
|
||||
add_index :attachments, [:flag_titlepic, :parent_type, :parent_id]
|
||||
add_index :neuigkeit_translations, :neuigkeit_id
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user