Commit 89f29395 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Reword Instance variables in views

parent 07d3d447
...@@ -216,13 +216,9 @@ other random objects, so they're still somewhat isolated. ...@@ -216,13 +216,9 @@ other random objects, so they're still somewhat isolated.
### Instance variables in views ### Instance variables in views
They're terrible, because they're also shared between different controllers, They're bad because we can't easily tell who's using the instance variables
and it's very hard to track where those instance variables were set when we (from controller's point of view) and where we set them up (from partials'
saw somewhere is using it, neither do we know where those were used when we point of view), making it extremely hard to track data dependency.
saw somewhere is setting up them. We hit into a number of 500 errors when we
tried to remove some instance variables in the controller in the past.
Somewhere, some partials might be using it, and we don't know.
We're trying to use something like this instead: We're trying to use something like this instead:
...@@ -238,5 +234,6 @@ And in the partial: ...@@ -238,5 +234,6 @@ And in the partial:
- project = local_assigns.fetch(:project) - project = local_assigns.fetch(:project)
``` ```
This way it's clearer where those values were coming from. In the future, This way it's clearer where those values were coming from, and we gain the
benefit to have typo check over using instance variables. In the future,
we should also forbid the use of instance variables in partials. we should also forbid the use of instance variables in partials.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment