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?
|
tree += render partial: 'tree/tree_item', collection: folders, locals: {type: 'folder'} if folders.present?
|
||||||
|
|
||||||
files.each do |f|
|
files.each do |f|
|
||||||
if f.respond_to?(:url)
|
html = if f.respond_to?(:url)
|
||||||
# Object is a Submodule
|
# Object is a Submodule
|
||||||
tree += render partial: 'tree/submodule_item', object: f
|
render partial: 'tree/submodule_item', object: f
|
||||||
else
|
else
|
||||||
# Object is a Blob
|
# Object is a Blob
|
||||||
tree += render partial: 'tree/tree_item', object: f, locals: {type: 'file'}
|
render partial: 'tree/tree_item', object: f, locals: {type: 'file'}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tree += html if html.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
tree.html_safe
|
tree.html_safe
|
||||||
|
|
Loading…
Add table
Reference in a new issue