diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 17b22df424a2443720ce4356c944032a737d1d3c..ecc8069a7f644a3d7886a0f8469927985b7fc35e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2,45 +2,40 @@ class UsersController < ApplicationController before_action :authenticate_user!, only: :me before_action :check_current_user_page, only: :show before_action :set_user, only: :show + before_action :set_empty_collection, only: [:show, :me] def show - @objects = learning_object_repository.all_from_offset_to_limit 0, 10 - @new_collection = Collection.new - + @objects = @user.learning_objects @groups = [ CollectionsGroup.new(title: 'Coleções Automáticas', collections: [ @new_collection ]), - CollectionsGroup.new(title: 'Coleções adicionadas', + CollectionsGroup.new(title: 'Coleções Adicionadas', collections: [ - @new_collection + @user.collections ]) ] end def me - @objects = learning_object_repository.all_from_offset_to_limit 0, 10 - @new_collection = Collection.new - @bookmarks = Collection.new(name: 'Favoritos') - @add1 = Collection.new(name: 'Aula fÃsica quantica - turma b') - @add2 = Collection.new(name: 'Aula segunda lei de newton - turma a') - + @objects = current_user.learning_objects + @bookmarks = current_user.bookmarks @groups = [ CollectionsGroup.new(title: 'Coleções Automáticas', - collections: [ - @bookmarks - ]), + collections: [@bookmarks]), CollectionsGroup.new(title: 'Coleções Adicionadas', - collections: [ - @add1, @add2 - ]) + collections: current_user.collections) ] end private + def set_empty_collection + @new_collection = Collection.new + end + def set_user @user = user_repository.find params[:id] end