SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2009
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Controller/View Instance Variable Access

    I'm learning ruby (on rails) and I put together this simple controller & view, which I can't figure out why is not working:

    Code:
    class NewsController < ApplicationController
      def index
        @currentTime = Time.now
      end
    end
    *Note: if I change @currentTime to Time.now the current time is displayed.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>News</title>
    </head>
    
    <body>
    <h1>News</h1>
    <p>The current time is:<%= @currentTime %></p>
    </body>
    </html>
    Help is appreciated.

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what did you name the view file?

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2009
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by docetes View Post
    what did you name the view file?
    I just started ruby/rails, and the problem ended up being something simple. The 'action' name did not match the view file name, resulting in the error.

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dan06 View Post
    I just started ruby/rails, and the problem ended up being something simple. The 'action' name did not match the view file name, resulting in the error.
    that's what I thought, those little things can be really annoying. Glad to hear you figured it out

  5. #5
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not that I think it's related to your particular problem, but the naming convensions in ruby is @current_time


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •