diff --git a/app/controllers/learning_objects_controller.rb b/app/controllers/learning_objects_controller.rb index 2c463af5a3cbfcb046d10e10bd1d3f2abffc838e..bf9aa4673982799d3ae19bf7b12fca045fbacd38 100644 --- a/app/controllers/learning_objects_controller.rb +++ b/app/controllers/learning_objects_controller.rb @@ -21,7 +21,7 @@ class LearningObjectsController < ApplicationController def new @learning_object = LearningObject.new @school_levels = ['EducaçÃĢo Infantil', 'Ensino Fundamental', 'Ensino MÃĐdio'] - @subjects = Topic.all.map{|x| x.name}.uniq + @subjects = Topic.default_list @types = LearningObject.default_types @languages = Language.all end @@ -112,7 +112,7 @@ class LearningObjectsController < ApplicationController def build_subjects(subjects) subjects.map do |subject| - subject_repository.find subject + Topic.find subject end end diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 70e9f5b69c8640ea40d04aa5e4e589df12ecd55a..9f2419b8e6b5bb51c0c28e166dbda875d09f762b 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,6 +1,6 @@ class SearchController < ApplicationController def index - @types = learning_object_repository.types + @types = LearningObject.default_types @subjects = Topic.default_list diff --git a/app/models/language.rb b/app/models/language.rb index cf4ab8bfa6a1b2d48103ec8495c6b3f2c22f04ad..0914f6255ea53469ceee105c3dec450fff72a068 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -1,6 +1,5 @@ class Language < ActiveRecord::Base - include RepositoriesProxy - include Metadatable - attr_accessor :id, :name, :code + has_many :learning_object + end diff --git a/app/models/learning_object.rb b/app/models/learning_object.rb index 9f0a88ce9b761a23c7fecca2d58600417546619b..49f6d468e10e86af330c7c47071ec4fd686343d6 100644 --- a/app/models/learning_object.rb +++ b/app/models/learning_object.rb @@ -15,6 +15,8 @@ class LearningObject < ActiveRecord::Base belongs_to :publisher, polymorphic: true + belongs_to :language + validates_presence_of :name, :id_dspace validates_uniqueness_of :id_dspace diff --git a/db/migrate/20160217114036_create_languages.rb b/db/migrate/20160217114036_create_languages.rb new file mode 100644 index 0000000000000000000000000000000000000000..f47d4742793b594adf539350404b87e04b24b4eb --- /dev/null +++ b/db/migrate/20160217114036_create_languages.rb @@ -0,0 +1,9 @@ +class CreateLanguages < ActiveRecord::Migration + def change + create_table :languages do |t| + t.string :name + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160217114745_remove_language_from_learning_object.rb b/db/migrate/20160217114745_remove_language_from_learning_object.rb new file mode 100644 index 0000000000000000000000000000000000000000..b0d5f335bd40712d8366b8e285c63e1a679e1563 --- /dev/null +++ b/db/migrate/20160217114745_remove_language_from_learning_object.rb @@ -0,0 +1,5 @@ +class RemoveLanguageFromLearningObject < ActiveRecord::Migration + def change + remove_column :learning_objects, :language, :string + end +end