mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-13 05:10:59 +00:00
Fix deprecated finds
This commit is contained in:
parent
39ce9c613f
commit
e855b46bd9
7 changed files with 15 additions and 7 deletions
|
@ -47,7 +47,7 @@ class GroupsController < ApplicationController
|
|||
end
|
||||
|
||||
def addUser
|
||||
@user = User.first conditions: {username: params[:username]}
|
||||
@user = User.where(username: params[:username])
|
||||
raise AccessError unless @group.can_update? cuser
|
||||
raise Error, t(:duplicate_user) if @group.users.include? @user
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ class ServersController < ApplicationController
|
|||
before_action :get_server, except: [:index, :refresh, :new, :create]
|
||||
|
||||
def index
|
||||
@servers = Server.hlds.active.ordered.all :include => :user
|
||||
@ns2 = Server.ns2.active.ordered.all :include => :user
|
||||
@servers = Server.hlds.active.ordered.includes(:user).all
|
||||
@ns2 = Server.ns2.active.ordered.includes(:user).all
|
||||
@officials = Server.ns2.active.ordered.where ["name LIKE ?", "%NSL%"]
|
||||
end
|
||||
|
||||
|
|
|
@ -178,6 +178,7 @@ module ApplicationHelper
|
|||
f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)")
|
||||
end
|
||||
|
||||
# FIXME: this won't work.
|
||||
def link_to_add_fields(name, f, association)
|
||||
new_object = f.object.class.reflect_on_association(association).klass.new
|
||||
fields = f.fields_for(association, new_object, child_index: "new_#{association}") do |builder|
|
||||
|
|
|
@ -121,11 +121,11 @@ class Article < ActiveRecord::Base
|
|||
if (new_record? or status_changed?) and status == STATUS_PUBLISHED
|
||||
case category.domain
|
||||
when Category::DOMAIN_NEWS
|
||||
Profile.includes(:user).all(conditions: "notify_news = 1").each do |p|
|
||||
Profile.includes(:user).where("notify_news = 1").each do |p|
|
||||
Notifications.news p.user, self if p.user
|
||||
end
|
||||
when Category::DOMAIN_ARTICLES
|
||||
Profile.includes(:user).all(conditions: "notify_articles = 1").each do |p|
|
||||
Profile.includes(:user).where("notify_articles = 1").each do |p|
|
||||
Notifications.article p.user, self if p.user
|
||||
end
|
||||
end
|
||||
|
|
|
@ -123,7 +123,7 @@ class DataFile < ActiveRecord::Base
|
|||
|
||||
if location.include? "_preview.mp4" and !related
|
||||
stripped = location.gsub(/_preview\.mp4/, "")
|
||||
DataFile.all(:conditions => ["path LIKE ?", stripped + "%"]).each do |r|
|
||||
DataFile.where(["path LIKE ?", stripped + "%"]).each do |r|
|
||||
if r.location.match(/#{stripped}\.\w{1,5}$/)
|
||||
self.related = r
|
||||
end
|
||||
|
|
|
@ -149,6 +149,7 @@ class Directory < ActiveRecord::Base
|
|||
strio = StringIO.new
|
||||
logger = Logger.new(strio)
|
||||
logger.info 'Starting recreate on Directory(%d): %s.' % [id, name]
|
||||
logger.info 'DataFiles: %d Directories: %d' % [DataFile.all.count, Directory.all.count]
|
||||
ActiveRecord::Base.transaction do
|
||||
# We use destroy lists so technically there can be seperate roots
|
||||
destroy_dirs = Hash.new
|
||||
|
@ -159,9 +160,11 @@ class Directory < ActiveRecord::Base
|
|||
destroy_dirs = recreate(destroy_dirs, logger: logger)
|
||||
destroy_dirs.each do |key, dir|
|
||||
logger.info 'Removed dir: %s' % dir.full_path
|
||||
dir.preserve_files = true
|
||||
dir.destroy!
|
||||
end
|
||||
end
|
||||
logger.info 'DataFiles: %d Directories: %d' % [DataFile.all.count, Directory.all.count]
|
||||
logger.info 'Finish recreate'
|
||||
return strio
|
||||
# TODO: check items that weren't checked.
|
||||
|
|
|
@ -4,7 +4,11 @@ class FileUploader < CarrierWave::Uploader::Base
|
|||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
model.directory.full_path
|
||||
if model and model.directory
|
||||
model.directory.full_path
|
||||
else
|
||||
Directory.find(Directory::ROOT).full_path
|
||||
end
|
||||
# .gsub(/public\//, '')
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue