distance_of_time_in_words

distance_of_time_in_words(from_time, to_time = 0, options = {}) Instance Public methods Reports the approximate distance in time between two Time, Date or DateTime objects or integers as seconds. Pass include_seconds: true if you want more detailed approximations when distance < 1 min, 29 secs. Distances are reported based on the following table: 0 <-> 29 secs # => less than a minute 30 secs <-> 1 min, 29

datetime_select

datetime_select(object_name, method, options = {}, html_options = {}) Instance Public methods Returns a set of select tags (one for year, month, day, hour, and minute) pre-selected for accessing a specified datetime-based attribute (identified by method) on an object assigned to the template (identified by object). If anything is passed in the html_options hash it will be applied to every select tag in the set. # Generates a datetime select that, when POSTed, will be stored in the

date_select

date_select(object_name, method, options = {}, html_options = {}) Instance Public methods Returns a set of select tags (one for year, month, and day) pre-selected for accessing a specified date-based attribute (identified by method) on an object assigned to the template (identified by object). Options :use_month_numbers - Set to true if you want to use month numbers rather than month names (e.g. â2â instead of âFebruaryâ). :use_two_digit_numbers - Set to true if you want to disp

csrf_meta_tags

csrf_meta_tags() Instance Public methods Returns meta tags âcsrf-paramâ and âcsrf-tokenâ with the name of the cross-site request forgery protection parameter and token, respectively. <head> <%= csrf_meta_tags %> </head> These are used to generate the dynamic forms that implement non-remote links with :method. You don't need to use these tags for regular forms as they generate their own hidden fields. For AJAX requests other than GETs, extract the âcsrf-tokenâ fr

csrf_meta_tag

csrf_meta_tag() Instance Public methods For backwards compatibility. csrf_meta_tags

provide

provide(name, content = nil, &block) Instance Public methods The same as content_for but when used with streaming flushes straight back to the layout. In other words, if you want to concatenate several times to the same buffer when rendering a given template, you should use content_for, if not, use provide to tell the layout to stop looking for more contents.

content_for?

content_for?(name) Instance Public methods #content_for? checks whether any content has been captured yet using `content_for`. Useful to render parts of your layout differently based on what is in your views. <%# This is the layout %> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>My Website</title> <%= yield :script %> </head> <body class="<%= content_for?(:right_col) ? 'two-column' : 'one-colum

content_for

content_for(name, content = nil, options = {}, &block) Instance Public methods Calling #content_for stores a block of markup in an identifier for later use. In order to access this stored content in other templates, helper modules or the layout, you would pass the identifier as an argument to content_for. Note: yield can still be used to retrieve the stored content, but calling yield doesn't work in helper modules, while content_for does. <% content_for :not_authorized do %&

capture

capture(*args) Instance Public methods The capture method allows you to extract part of a template into a variable. You can then use this variable anywhere in your templates or layout. The capture method can be used in ERB templates⦠<% @greeting = capture do %> Welcome to my shiny new web page! The date and time is <%= Time.now %> <% end %> â¦and Builder (RXML) templates. @timestamp = capture do "The current timestamp is #{Time.now}." end You can then us

cache_unless

cache_unless(condition, name = {}, options = nil, &block) Instance Public methods Cache fragments of a view unless condition is true <%= cache_unless admin?, project do %> <b>All the topics on this project</b> <%= render project.topics %> <% end %>