Christopher Govender says:This code should go in /views/application.html.erb after the ‘contact’ link in the side column. ...
Then you should go to /stylesheets/application.css.scss and add – color: #bfb to the nested li selector. It will then be visible.
The code should not be
<%= Time.now.strftime("%I:%M %p) %>,
It should be
<%= Time.now.strftime('%I:%M %p‘) %>
Jakub Tuček asks:Tried two different ways how to set this outside of the view inspired by stack overflow .
- First with helper method in app/controller/application_controller.rb
in the view then just
class ApplicationController < ActionController::Base * helper_method :date_loaded * def date_loaded * return Time.now * end ...
<%= date_loaded %>
- Second setting what should be called before (do not know what) in the controller
and in view
class ApplicationController < ActionController::Base * before_filter :set_date * def set_date * @date_loaded = Time.now * end ...
<%= @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.
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 Time.now, :format => :short %> or :long if you prefer.
The time is barely visible due to the style.
- V19: David Hislop [almost 2 years ago]
- V18: David Hislop [almost 2 years ago]
- V17: David Hislop [almost 2 years ago]
- V16: Dennis Sutch [about 3 years ago]
- V19: Warren Bain [about 4 years ago]
- V18: Jakub Tuček [over 4 years ago]
- V17: Jakub Tuček [over 4 years ago]
- V16: Jakub Tuček [over 4 years ago]
- V15: Jakub Tuček [over 4 years ago]
- V14: Jakub Tuček [over 4 years ago]