# Problems with Instance Variable in Controllenr

**URL:** <https://discuss.rubyonrails.org/t/problems-with-instance-variable-in-controllenr/69813>\
**Category:** rubyonrails-talk\
**Created:** [November 5, 2014, 3:10pm UTC](https://discuss.rubyonrails.org/t/problems-with-instance-variable-in-controllenr/69813 "2014-11-05T15:10:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [November 5, 2014, 3:10pm UTC](https://discuss.rubyonrails.org/t/problems-with-instance-variable-in-controllenr/69813/1 "2014-11-05T15:10:13Z")

</div>

I've got problems with an instance variable in a controller. the varible is initialized and has some entries which i give out in the second view(create). but in the third view (export) I become back this message: ...............ActionView::Template::Error (undefined method `length' for nil:NilClass): &nbsp;&nbsp;&nbsp;&nbsp;1: \<%=@month\_issues.class%\> &nbsp;&nbsp;&nbsp;&nbsp;2: \<%=@month\_issues.length%\> &nbsp;&nbsp;&nbsp;&nbsp;3: \<%@month\_issues.each do |mi|%\> &nbsp;&nbsp;&nbsp;&nbsp;4: \<%= mi.text %\> &nbsp;&nbsp;&nbsp;&nbsp;5: \<%end%\> &nbsp;&nbsp;plugins/abrechnung/app/views/abrechnung/export.html.erb:2:in `\_plugins\_abrechnung\_app\_views\_abrech nung\_export\_html\_erb\_\_\_625827306\_55588872'............. But in abrechnung\_controller the vaiable is initialised as Array with some antries, how it can be nil?

Attachments: [http://www.ruby-forum.com/attachment/10248/abrechnung\_controller.rb](http://www.ruby-forum.com/attachment/10248/abrechnung_controller.rb)[http://www.ruby-forum.com/attachment/10249/month\_issue.rb](http://www.ruby-forum.com/attachment/10249/month_issue.rb)[http://www.ruby-forum.com/attachment/10250/export.html.erb](http://www.ruby-forum.com/attachment/10250/export.html.erb)[http://www.ruby-forum.com/attachment/10251/routes.rb](http://www.ruby-forum.com/attachment/10251/routes.rb)

---

<div class="post-metadata">

**Author:** ![Scott\_Ribe](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@Scott\_Ribe](https://discuss.rubyonrails.org/u/Scott_Ribe)\
**Post date:** [November 5, 2014, 3:25pm UTC](https://discuss.rubyonrails.org/t/problems-with-instance-variable-in-controllenr/69813/2 "2014-11-05T15:25:43Z")

</div>

You realize instance variables are not carried forward from one action to another? They have to be set up on each request.
