Skip to content
Snippets Groups Projects
Commit 94c46a54 authored by Marcela Ribeiro de Oliveira's avatar Marcela Ribeiro de Oliveira
Browse files

fix subjects and types

parent ce6ed498
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,7 @@ class LearningObjectsController < ApplicationController ...@@ -21,7 +21,7 @@ class LearningObjectsController < ApplicationController
def new def new
@learning_object = LearningObject.new @learning_object = LearningObject.new
@school_levels = ['Educação Infantil', 'Ensino Fundamental', 'Ensino Médio'] @school_levels = ['Educação Infantil', 'Ensino Fundamental', 'Ensino Médio']
# @subjects = Subject.default_list @subjects = Topic.all.map{|x| x.name}.uniq
@types = LearningObject.default_types @types = LearningObject.default_types
@languages = Language.all @languages = Language.all
end end
......
class SubjectsController < ApplicationController
# GET /subjects
# GET /subjects.json
def index
@subjects = Topic.all
end
# GET /subjects/1
# GET /subjects/1.json
def show
@general = []
mainPage = main_page_repository.all.first
@general = mainPage["highlights"].take(3).collect do |id|
LearningObject.find(id)
end
end
private
# Never trust parameters from the scary internet, only allow the white list through.
def subject_params
params[:subject_object]
end
end
...@@ -51,7 +51,7 @@ class LearningObject < ActiveRecord::Base ...@@ -51,7 +51,7 @@ class LearningObject < ActiveRecord::Base
def self.default_types def self.default_types
Rails.cache.fetch("cache/object_type", expires_in: 24.hours) do Rails.cache.fetch("cache/object_type", expires_in: 24.hours) do
LearningObject.select(:object_type).uniq LearningObject.group(:object_type).count.reject{|type, frequency| type.blank?}.map{|type, frequency| type}
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment