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: <html> <head> <title>Is This Ever Going To Work</title> </head> <body> <p>it is now <%= @time %></p> </body> </html> 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 <tmac@easystreet.com> wrote:> 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: > > <html> > <head> > <title>Is This Ever Going To Work</title> > </head> > <body> > <p>it is now <%= @time %></p> > </body> > </html> > > 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > 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. -- Zack Chandler http://depixelate.com
Already tried that and no go! Thanks for the response though Zack... any other ideas? Tim On Aug 17, 2006, at 3:52 PM, Zack Chandler wrote:> On 8/17/06, Tim McIntyre <tmac@easystreet.com> wrote: >> 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: >> >> <html> >> <head> >> <title>Is This Ever Going To Work</title> >> </head> >> <body> >> <p>it is now <%= @time %></p> >> </body> >> </html> >> >> 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 >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> 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. > > -- > Zack Chandler > http://depixelate.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 8/17/06, Tim McIntyre <tmac@easystreet.com> wrote:> Already tried that and no go! > > Thanks for the response though Zack... any other ideas? > > Tim > > On Aug 17, 2006, at 3:52 PM, Zack Chandler wrote: > > > On 8/17/06, Tim McIntyre <tmac@easystreet.com> wrote: > >> 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: > >> > >> <html> > >> <head> > >> <title>Is This Ever Going To Work</title> > >> </head> > >> <body> > >> <p>it is now <%= @time %></p> > >> </body> > >> </html> > >> > >> 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 > >> _______________________________________________ > >> Rails mailing list > >> Rails@lists.rubyonrails.org > >> 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. > > > > -- > > Zack Chandler > > http://depixelate.com > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > 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. -- Zack Chandler http://depixelate.com
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 On Aug 17, 2006, at 4:05 PM, Zack Chandler wrote:> On 8/17/06, Tim McIntyre <tmac@easystreet.com> wrote: >> Already tried that and no go! >> >> Thanks for the response though Zack... any other ideas? >> >> Tim >> >> On Aug 17, 2006, at 3:52 PM, Zack Chandler wrote: >> >> > On 8/17/06, Tim McIntyre <tmac@easystreet.com> wrote: >> >> 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: >> >> >> >> <html> >> >> <head> >> >> <title>Is This Ever Going To Work</title> >> >> </head> >> >> <body> >> >> <p>it is now <%= @time %></p> >> >> </body> >> >> </html> >> >> >> >> 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 >> >> _______________________________________________ >> >> Rails mailing list >> >> Rails@lists.rubyonrails.org >> >> 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. >> > >> > -- >> > Zack Chandler >> > http://depixelate.com >> > _______________________________________________ >> > Rails mailing list >> > Rails@lists.rubyonrails.org >> > http://lists.rubyonrails.org/mailman/listinfo/rails >> > >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> 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. > > -- > Zack Chandler > http://depixelate.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Help save a life... please! On Aug 17, 2006, at 3:39 PM, Tim McIntyre wrote:> 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: > > <html> > <head> > <title>Is This Ever Going To Work</title> > </head> > <body> > <p>it is now <%= @time %></p> > </body> > </html> > > 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
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: <html> <head> <title>Is This Ever Going To Work</title> </head> <body> <p>The time is <%= @time %></p> </body> </html> 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 On Aug 17, 2006, at 5:02 PM, Tim McIntyre wrote:> Help save a life... please! > > On Aug 17, 2006, at 3:39 PM, Tim McIntyre wrote: > >> 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: >> >> <html> >> <head> >> <title>Is This Ever Going To Work</title> >> </head> >> <body> >> <p>it is now <%= @time %></p> >> </body> >> </html> >> >> 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 >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
what are your files called? what url are you using? Max On 8/18/06, Tim McIntyre <tmac@easystreet.com> wrote:> Help save a life... please! > > On Aug 17, 2006, at 3:39 PM, Tim McIntyre wrote: > > > 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: > > > > <html> > > <head> > > <title>Is This Ever Going To Work</title> > > </head> > > <body> > > <p>it is now <%= @time %></p> > > </body> > > </html> > > > > 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 > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
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: <html> <head> <title>Is This Ever Going To Work</title> </head> <body> <p>The time is <%= @time %></p> </body> </html> 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 On Aug 17, 2006, at 10:53 PM, Max Muermann wrote:> what are your files called? what url are you using? > > Max > > On 8/18/06, Tim McIntyre <tmac@easystreet.com> wrote: >> Help save a life... please! >> >> On Aug 17, 2006, at 3:39 PM, Tim McIntyre wrote: >> >> > 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: >> > >> > <html> >> > <head> >> > <title>Is This Ever Going To Work</title> >> > </head> >> > <body> >> > <p>it is now <%= @time %></p> >> > </body> >> > </html> >> > >> > 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 >> > _______________________________________________ >> > Rails mailing list >> > Rails@lists.rubyonrails.org >> > http://lists.rubyonrails.org/mailman/listinfo/rails >> > >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060818/7037aee7/attachment-0001.html