small medium large xlarge


Christopher Govender says:

This code should go in /views/application.html.erb after the ‘contact’ link in the side column. ...
  • <%=“%I:%M %p) %>
  • Then you should go to /stylesheets/application.css.scss and add – color: #bfb to the nested li selector. It will then be visible.

    Young says:

    The code should not be <%="%I:%M %p) %>, It should be <%='%I:%M %p‘) %>

    Jakub Tuček asks:

    Tried two different ways how to set this outside of the view inspired by stack overflow .
    1. First with helper method in app/controller/application_controller.rb
      class ApplicationController < ActionController::Base
      *  helper_method :date_loaded
      *  def date_loaded
      *    return
      *  end
      in the view then just <%= date_loaded %>
    2. Second setting what should be called before (do not know what) in the controller
      class ApplicationController < ActionController::Base
      *  before_filter :set_date
      *  def set_date
      *    @date_loaded =
      *  end
      and in view <%= @date_loaded %>

    I consider first the best, prepare helper (maybe in different location, do not know yet) and use it in layout, but if there is some reason to prefer other way (hardcode in layout, or local attribute), could someone please explain why? thanks in advance.

    Wazza says:

    As an Australian i.e. not US date formats, I think you should use the I18n helper to localise the answer. It should be <%= l, :format => :short %> or :long if you prefer.

    sutch says:

    The time is barely visible due to the style.

    David says:

    As often said of another popular scripting language, there is more than one way to do it. Here’s what I did:

    1. Get the current date-time: in app/controllers/application_controller.rb add these lines to create an instance variable containing the date-time:
        before_action :set_date_loaded
        def set_date_loaded
          @date_loaded =
    2. Display the time in the sidebar: in app/views/layouts/application.html.erb add this line
              <p><%= l @date_loaded, :format => :short %></p>
      just after the line
              <li><a href="http://www..../contact">Contact</a></li>
    3. Set a visible font colour: in app/assets/stylesheets/application.css.scss add these lines
          p {
            color: #bfb;
            font-size: small;
      inside the
      #side { ... } 
      block just after the
      ul { ... }
    4. Refresh the Store and Product pages.
    Page History
    • V19: David Hislop [over 3 years ago]
    • V18: David Hislop [over 3 years ago]
    • V17: David Hislop [over 3 years ago]
    • V16: Dennis Sutch [over 4 years ago]
    • V19: Warren Bain [over 5 years ago]
    • V18: Jakub Tuček [almost 6 years ago]
    • V17: Jakub Tuček [almost 6 years ago]
    • V16: Jakub Tuček [almost 6 years ago]
    • V15: Jakub Tuček [almost 6 years ago]
    • V14: Jakub Tuček [almost 6 years ago]