From 97ab21a681c9b422aba2eea1fae7b775a1139c0b Mon Sep 17 00:00:00 2001
From: Slawek Kwasniewski
Date: Sun, 19 May 2013 14:32:32 +0200
Subject: [PATCH] no more errors when repo doesn't have a group assigned
---
app/controllers/repositories_controller.rb | 14 +++++++++++---
app/views/repositories/show.html.erb | 14 +++++++++-----
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 9aaccaf..eb6db5d 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -45,10 +45,18 @@ def edit
def show
@repository = Repository.find(params[:id])
- @gtr = Grouptorepo.where("repository_id = ?", params[:id]).select("group_id").first
- @x = Group.where("id = ?", @gtr.group_id).select("group_name").first
- @usr = Usertogroup.where("group_id = ?", @gtr.group_id).all
+ if (@repository != nil)
+ @gtr = Grouptorepo.where("repository_id = ?", params[:id]).select("group_id").first
+ end
+
+ if (@gtr != nil)
+ @x = Group.where("id = ?", @gtr.group_id).select("group_name").first
+ end
+
+ if (@gtr != nil)
+ @usr = Usertogroup.where("group_id = ?", @gtr.group_id).all
+ end
@htr = Hook.all
# @htr = Repohook.where("repository_id = ?", params[:id]).all
diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb
index 7796e35..76dcf45 100644
--- a/app/views/repositories/show.html.erb
+++ b/app/views/repositories/show.html.erb
@@ -10,15 +10,19 @@
Group:
+ <% if (@x != nil) %>
<%= @x.group_name %>
+ <% end %>
Members:
- <% @usr.each do |f| %>
- <% (User.where("id = ?", f.user_id).select("email").all).each do |z|%>
- <%= z.email %>
-
- <% end %>
+ <% if @usr != nil %>
+ <% @usr.each do |f| %>
+ <% (User.where("id = ?", f.user_id).select("email").all).each do |z|%>
+ <%= z.email %>
+
+ <% end %>
+ <% end %>
<% end %>