tag_name从ProjectInfo取用户抛错的问题

不查询网站信息(删东西
gemfile加pry判定
president
yanxd 11 years ago
parent 2e9251530c
commit 789a8d1392

@ -19,6 +19,10 @@ gem 'acts-as-taggable-on'
group :development do group :development do
gem 'better_errors', path: 'lib/better_errors' gem 'better_errors', path: 'lib/better_errors'
gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler' gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler'
if ENV['PRY']
gem 'pry'
gem 'pry-nav'
end
end end
# Gems used only for assets and not required # Gems used only for assets and not required

@ -21,13 +21,7 @@ class WelcomeController < ApplicationController
before_filter :entry_select_course, :entry_select_contest, :entry_select_user, :only => [:index] before_filter :entry_select_course, :entry_select_contest, :entry_select_user, :only => [:index]
def index def index
projectActive = Project.project_entities.active
@projectCount = projectActive.count
@projectPublicCount = projectActive.all_public.count
@projectHidenCount = @projectCount - @projectPublicCount
@developerCount = User.developer.count
@allUsercount = User.count
end end
def robots def robots
@ -36,10 +30,7 @@ class WelcomeController < ApplicationController
end end
def course def course
@courseCount = Project.course_entities.count @logoLink ||= logolink()
@teacherCount = User.teacher.count
@studentCount = User.student.count
@logoLink = logolink()
end end
@ -121,25 +112,25 @@ class WelcomeController < ApplicationController
end end
end end
def render(*args) # def render(*args)
_fake if @fake_filter # _fake if @fake_filter
super # super
end # end
private # private
def fake # def fake
@fake_filter = true # @fake_filter = true
end # end
# 骗子方法 # # 骗子方法
def _fake # def _fake
instance_variables.map { |variable| # instance_variables.map { |variable|
if variable.to_s =~ /Count$/ # if variable.to_s =~ /Count$/
self.instance_variable_set(variable.to_sym, # self.instance_variable_set(variable.to_sym,
("1" + (self.instance_variable_get(variable.to_sym).to_s)).to_i) # ("1" + (self.instance_variable_get(variable.to_sym).to_s)).to_i)
end # end
} # }
end # end
end end

@ -51,14 +51,14 @@
<% when '2' %> <% when '2' %>
<% if (ProjectInfo.find_by_project_id(obj.id)).user_id == User.current.id %> <% if (ProjectInfo.find_by_project_id(obj.id)).try(:user_id) == User.current.id %>
<span class='del'> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, <span class='del'> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag,
:taggable_id => obj.id, :taggable_type => object_flag %> </span> :taggable_id => obj.id, :taggable_type => object_flag %> </span>
<% end %> <% end %>
<% when '3' %> <% when '3' %>
<% if (ProjectInfo.find_by_project_id(obj.project_id)).user_id == User.current.id %> <% if (ProjectInfo.find_by_project_id(obj.project_id)).try(:user_id) == User.current.id %>
<span class='del'> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag, <span class='del'> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag,
:taggable_id => obj.id, :taggable_type => object_flag %> </span> :taggable_id => obj.id, :taggable_type => object_flag %> </span>
<% end %> <% end %>

@ -259,17 +259,4 @@
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
<div class="hidden" style="width:100%;">
<div style="width:600px;margin:0px auto;margin-top:80px;">
<table style="width:600px;font-size:15px; color: #e8770d;">
<tr>
<td><strong>当前网站状态</strong></td>
<td>活跃课程: <%=@courseCount%></td>
<td>高校: 2个</td>
<td>教师: <%=@teacherCount%> 名</td>
<td>学生: <%=@studentCount%> 名<td>
</tr>
</table>
</div>
</div>
<%= render partial: 'link_to_another' %> <%= render partial: 'link_to_another' %>

@ -137,16 +137,4 @@
<div class="clearfix"></div> <div class="clearfix"></div>
<div class="hidden" style="width:100%;">
<div style="width:600px;margin:0px auto;margin-top:180px;">
<table style="width:600px;font-size:15px; color: gray;">
<tr>
<td><strong>当前网站状态</strong></td>
<td>活跃项目:<%=@projectCount%>个</td>
<td>私有项目: <%=@projectHidenCount%>个</td>
<td>开发者:<%=@allUsercount%>个 </td>
</tr>
</table>
</div>
</div>
<%= render partial: 'link_to_another' %> <%= render partial: 'link_to_another' %>
Loading…
Cancel
Save