Views losing values of Controller instance variables.

Since moving my app from local to my host (and moving from development
to production) I've run into some very odd issues. I've searched
around for the past day or so and can't find anything to answer my
query! So I'm hoping someone else has run into this.

My instance variables are losing their values when trying to display
them in a view. Sometimes.

I've got a projects section

The index method in the controller looks like

def index
    @projects = Project.find(:all)
    @test = 'test'

My view (using markaby)

for p in @projects
      li { link_to, :action => :show, :id => p }

- this works correctly on my local machine, i've also switched it back
to rhtml files and that works correctly also

on my hosted server it gives me the "We're sorry, but something went
wrong." message - looking into the production.log file it tells me

ActionView::TemplateError (undefined method `each' for nil:NilClass)

so for some reason the @projects isn't defined
if i try debug @projects it returns '---'

just to see if anything would go through i set a test variable @test =
'this is a test string'
and tried to output that. displays nothing and debug gives me the
same '---' message.

The strange thing is inside of an Admin controller I have a
list_projects method that mirrors the index method of the Projects
controller and it's views work exactly as they should. So the same
for loop above works correctly.

Anyone have any idea what's going on here, I can't figure out why it's
affecting one controller only and I haven't been able to find anything
that might point me in the right direction - so any help would be much

thanks in advance for any help, pointers, info!


Not sure why this might be happening but whenever it's happened to me, I
just put something like:

@projects = []

inside the initialize method and it goes away.

Arshak wrote: