tree_heleper: concat html only if present. Avoid nil exception
This commit is contained in:
parent
9ba21dd0c4
commit
a99ad3d355
1 changed files with 9 additions and 7 deletions
|
@ -13,13 +13,15 @@ module TreeHelper
|
|||
tree += render partial: 'tree/tree_item', collection: folders, locals: {type: 'folder'} if folders.present?
|
||||
|
||||
files.each do |f|
|
||||
if f.respond_to?(:url)
|
||||
# Object is a Submodule
|
||||
tree += render partial: 'tree/submodule_item', object: f
|
||||
else
|
||||
# Object is a Blob
|
||||
tree += render partial: 'tree/tree_item', object: f, locals: {type: 'file'}
|
||||
end
|
||||
html = if f.respond_to?(:url)
|
||||
# Object is a Submodule
|
||||
render partial: 'tree/submodule_item', object: f
|
||||
else
|
||||
# Object is a Blob
|
||||
render partial: 'tree/tree_item', object: f, locals: {type: 'file'}
|
||||
end
|
||||
|
||||
tree += html if html.present?
|
||||
end
|
||||
|
||||
tree.html_safe
|
||||
|
|
Loading…
Add table
Reference in a new issue