aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-07-03 18:44:29 +0200
committerTeddy Wing2017-07-06 12:30:59 +0200
commit8a2818897911e5b33af6849e2ea648ae6e014eef (patch)
tree7106d01eec7c14827511c716b4bd19440384962c
parent205ce7c3fbdb025edc62a74b87d26cc237545f36 (diff)
downloadchouette-core-8a2818897911e5b33af6849e2ea648ae6e014eef.tar.bz2
TableBuilderHelper: Fix NoMethodError when `current_referential` undef
Certain controllers (`Calendar` and `Referential`) don't define a `#current_referential` method. In those cases, we'd get a `NoMethodError` in this function when calling `#current_referential`. To avoid the error, give `current_referential` a default value. Using a default of `nil` works here because the current referential is needed in other places in order to build links. Since the links in the special models don't need a referential in order to be built, we don't care that the value is `nil`. Refs #3479
-rw-r--r--app/helpers/table_builder_helper.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index d748ec33a..1ddd629f8 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -104,6 +104,10 @@ module TableBuilderHelper
end
def tbody(collection, columns, selectable, links)
+ # Certain controllers don't define a `#current_referential`. If the method
+ # is unavailable, give it a default value to avoid a `NoMethodError`.
+ current_referential ||= nil
+
content_tag :tbody do
collection.map do |item|