Hey all,
Well… hmm… feeling pretty stupid here…
For some reason my controller instance variables are not displaying
in my templates. I’ve boiled it down to this test case.
class Rss::FilmController < ApplicationController
def display
@time = Time.now
end
end
and the template:
Is This Ever Going To Work
it is now <%= @time %>
that’s it!
When I hit that with the browser all I get is the html? I can put
ruby in the template and that works fine but nothing from the
controller? This is basically the same as the code right from
chapter 4 of the agile web dev book. I must be missing something
terribly obvious.
That’s running under webrick, when I run from Apache all I get is
“Rails application failed to start properly” error. From what I can
tell that should all be configured correctly too. If anyone has
idea’s (don’t think they are related, but I guess you never know)
on that one that would be great too!
Thanks in advance!
Tim
On 8/17/06, Tim McIntyre [email protected] wrote:
@time = Time.now
terribly obvious.
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
Tim,
Normally you would simply put
<%= @time.to_s %>
in the template. Then this template gets included in you layout
(probably application.rhtml). Try that as a first step.
Already tried that and no go!
Thanks for the response though Zack… any other ideas?
Tim
Hey
Yeah, did all that too. Any ruby code I put directly in the template
works fine it’s just that I get nothing from the controller even
though it is obviously detecting the display method.
HELP HELP HELP!
Thanks again!
Tim
Help save a life… please!
On 8/17/06, Tim McIntyre [email protected] wrote:
</body>
That’s running under webrick, when I run from Apache all I get is
http://lists.rubyonrails.org/mailman/listinfo/rails
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
Tim,
Make sure your display.rhtml template is being called by adding:
It is <%= Time.now.to_s %>
Refresh the page a few times and the value should change. Maybe it’s
a caching thing. Also I would clear the brower cache, delete all
session files (rake tmp:clear), restart ./script/server, AND close and
reopen your browser.
what are your files called? what url are you using?
Max
Apparently rails chokes a bit on controller methods named “display”.
I don’t know if this is a bug or if I missed some bit of
documentation or ???
Here is my test case:
class Rss::FilmController < ApplicationController
def test
@time = Time.now
end
def display
@time = Time.now
end
end
Then two identical templates just like so:
Is This Ever Going To Work
The time is <%= @time %>
localhost/rss/film/display does not work… the html displays but
@time does not
localhost/rss/film/test works perfectly… with @time and all
Anyone have any thoughts on this???
Thanks!
Tim
Hey Max,
Thanks for the reply… I found the problem but it still seems
weird. I started another thread with the subject “Bug? was -
instance variables in templates” but here it is again:
Must be overriding a display method in app controller or something…
seems that it should be documented though?
Apparently rails chokes a bit on controller methods named “display”.
I don’t know if this is a bug or if I missed some bit of
documentation or ???
Here is my test case:
class Rss::FilmController < ApplicationController
def test
@time = Time.now
end
def display
@time = Time.now
end
end
Then two identical templates just like so:
Is This Ever Going To Work
The time is <%= @time %>
localhost/rss/film/display does not work… the html displays but
@time does not
localhost/rss/film/test works perfectly… with @time and all
Anyone have any thoughts on this???
Thanks!
Tim