diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9506359bd..ad82858de 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -493,6 +493,7 @@ class UsersController < ApplicationController end end #### end + def new @user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option) @@ -544,14 +545,7 @@ class UsersController < ApplicationController end def watch_projects - @watch_type = Watcher.where("watchable_type = ? and user_id = ?", 'Project', @user.id) - #@project = Project.visible.where("project_type < ?", 1) - @watch_projects = [] - unless @watch_type.nil? - @watch_type.each do |obj| - @watch_projects << Project.find(obj.watchable_id) - end - end + @watch_projects = Project.joins(:watchers).where("project_type <>? and watchable_type = ? and user_id = ?", '1','Project', @user.id) @state = 1 respond_to do |format| format.html { diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 8d4a56aae..4ba39cfd1 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -21,7 +21,6 @@ include AvatarHelper module UsersHelper - def users_status_options_for_select(selected) user_count_by_status = User.count(:group => 'status').to_hash options_for_select([[l(:label_all), ''], diff --git a/app/views/users/watch_projects.html.erb b/app/views/users/watch_projects.html.erb index de2da9497..c3bd8d3fb 100644 --- a/app/views/users/watch_projects.html.erb +++ b/app/views/users/watch_projects.html.erb @@ -3,7 +3,7 @@ <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new', :course => 0, :project_type => @project_type}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> <% end %> <%= watch_projects @state%> -<% unless @watch_projects.nil?&&watch_projects.project.nil? %> +<% if @watch_projects.nil?&&watch_projects.project.nil? %> <% for watch_project in @watch_projects %>