Hi all.
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
def Hello
@text = 'Hello world from the controller'
end
def Goodbye
end
end
This is my view:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Rails test (say)</title>
</head>
<body>
<p>Hello world!</p>
<p><%= 'testje ' + @text %></p>
</body>
</html>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk@...
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@...
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en-~----------~----~----~----~------~----~------~--~---