I’m new to RoR and trying to figure out instance variables. I’m trying
to put a string in one in the controller and
print it in the view. However I’m getting the following error:
NoMethodError in Say#hello
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.+
Apparently the @text variable remains nil, even though I assign a
string to it. Any ideas about what goes wrong?
This is my controller code:
class SayController < ApplicationController
@text = ‘Hello world from the controller’
This is my view:Rails test (say)
<%= 'testje ' + @text %>