fetch stores/index instance_object
This commit is contained in:
parent
3d2c0ba721
commit
f91d94fd4c
|
@ -7,8 +7,22 @@ class StoresController < ApplicationController
|
||||||
# menu_item :settings, :only => :settings
|
# menu_item :settings, :only => :settings
|
||||||
|
|
||||||
# include ActsAsTaggableOn::TagsHelper
|
# include ActsAsTaggableOn::TagsHelper
|
||||||
|
LIMIT = 20 unless const_defined?(:LIMIT)
|
||||||
def index
|
def index
|
||||||
|
#Document HomeworkAttach Issue Message News Version WikiPage
|
||||||
|
projects_attach
|
||||||
|
@projects_attach = Attachment.includes(:attach_project).where("projects.project_type=?", 0).
|
||||||
|
reorder("#{Attachment.table_name}.created_on DESC").
|
||||||
|
limit(LIMIT)
|
||||||
|
@courses_attach = Attachment.includes(:attach_project).where("projects.project_type=?", 1).
|
||||||
|
reorder("#{Attachment.table_name}.created_on DESC").
|
||||||
|
limit(LIMIT)
|
||||||
|
@homeworks_attach = Attachment.where("container_type = 'HomeworkAttach'").
|
||||||
|
reorder("created_on DESC").
|
||||||
|
limit(LIMIT)
|
||||||
|
@memos_attach = Attachment.where("container_type = 'Memo'").
|
||||||
|
reorder("created_on DESC").
|
||||||
|
limit(LIMIT)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -268,7 +268,8 @@ module ProjectsHelper
|
||||||
@projects << Project.visible.find_by_id("#{obj.project_id}")#where('id=:id', id: obj.project_id)
|
@projects << Project.visible.find_by_id("#{obj.project_id}")#where('id=:id', id: obj.project_id)
|
||||||
end
|
end
|
||||||
@projects
|
@projects
|
||||||
rescue NoMethodError
|
rescue NoMethodError => e
|
||||||
|
logger.error "Logger.Error [ProjectsHelper] ===> #sort_project_by_hot, NoMethodError: #{e}"
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -285,4 +286,7 @@ module ProjectsHelper
|
||||||
WHERE project_type = 0 ORDER BY grade DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ")
|
WHERE project_type = 0 ORDER BY grade DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def method_name
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -66,7 +66,7 @@ module WelcomeHelper
|
||||||
begin
|
begin
|
||||||
grade = project.project_status.grade if project && project.project_status
|
grade = project.project_status.grade if project && project.project_status
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
logger.error "[WelcomeHelper] ===> #{e}"
|
logger.error "Logger.Error [WelcomeHelper] ===> #{e}"
|
||||||
end
|
end
|
||||||
"项目评分:".html_safe << grade.to_s
|
"项目评分:".html_safe << grade.to_s
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,6 +20,7 @@ require "fileutils"
|
||||||
|
|
||||||
class Attachment < ActiveRecord::Base
|
class Attachment < ActiveRecord::Base
|
||||||
belongs_to :container, :polymorphic => true
|
belongs_to :container, :polymorphic => true
|
||||||
|
belongs_to :attach_project, foreign_key: 'container_id', conditions: "#{Attachment.table_name}.container_type = 'Project'"
|
||||||
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
|
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
|
||||||
|
|
||||||
validates_presence_of :filename, :author
|
validates_presence_of :filename, :author
|
||||||
|
|
|
@ -151,6 +151,8 @@ class Project < ActiveRecord::Base
|
||||||
where("LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p ", :p => pattern)
|
where("LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p ", :p => pattern)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
scope :project_entities, -> { where(project_type: 0) }
|
||||||
|
scope :course_entities, -> { where(project_type: 1) }
|
||||||
|
|
||||||
def new_course
|
def new_course
|
||||||
self.where('project_type = ?', 1)
|
self.where('project_type = ?', 1)
|
||||||
|
|
Loading…
Reference in New Issue