HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/gems/ruby-3.0.2/doc/actionpack-6.1.4.1/ri/ActionController/Helpers/cdesc-Helpers.ri
U:RDoc::NormalModule[iI"Helpers:ETI"ActionController::Helpers;T0o:RDoc::Markup::Document:@parts[o;;[o:RDoc::Markup::Paragraph;[I"dThe \Rails framework provides a large number of helpers for working with assets, dates, forms, ;TI"\numbers and model objects, to name a few. These helpers are available to all templates ;TI"by default.;To:RDoc::Markup::BlankLineo;	;[I"]In addition to using the standard template helpers provided, creating custom helpers to ;TI"mextract complicated logic or reusable functionality is strongly encouraged. By default, each controller ;TI"lwill include all helpers. These helpers are only accessible on the controller through <tt>#helpers</tt>;T@o;	;[I"OIn previous versions of \Rails the controller will include a helper which ;TI"Xmatches the name of the controller, e.g., <tt>MyController</tt> will automatically ;TI"Vinclude <tt>MyHelper</tt>. You can revert to the old behavior with the following:;T@o:RDoc::Markup::Verbatim;[	I"# config/application.rb
;TI",class Application < Rails::Application
;TI"<  config.action_controller.include_all_helpers = false
;TI"	end
;T:@format0o;	;[I"jAdditional helpers can be specified using the +helper+ class method in ActionController::Base or any ;TI"'controller which inherits from it.;T@o;	;[I"mThe +to_s+ method from the \Time class can be wrapped in a helper method to display a custom message if ;TI"a \Time object is blank:;T@o;;[
I" module FormattedTimeHelper
;TI"C  def format_time(time, format=:long, blank_message="&nbsp;")
;TI"9    time.blank? ? blank_message : time.to_s(format)
;TI"  end
;TI"	end
;T;0o;	;[I"^FormattedTimeHelper can now be included in a controller, using the +helper+ class method:;T@o;;[I"5class EventsController < ActionController::Base
;TI""  helper FormattedTimeHelper
;TI"  def index
;TI"    @events = Event.all
;TI"  end
;TI"	end
;T;0o;	;[I"lThen, in any view rendered by <tt>EventsController</tt>, the <tt>format_time</tt> method can be called:;T@o;;[
I"$<% @events.each do |event| -%>
;TI"  <p>
;TI"K    <%= format_time(event.time, :short, "N/A") %> | <%= event.name %>
;TI"  </p>
;TI"<% end -%>
;T;0o;	;[I"aFinally, assuming we have two event instances, one which has a time and one which does not, ;TI"%the output might look like this:;T@o;;[I"423 Aug 11:30 | Carolina Railhawks Soccer Match
;TI"/N/A | Carolina Railhawks Training Workshop;T;0:
@fileI"+lib/action_controller/metal/helpers.rb;T:0@omit_headings_from_table_of_contents_below0;
0;0[[
I"helpers_path;TI"RW;T:publicTI"+lib/action_controller/metal/helpers.rb;T[[[I" AbstractController::Helpers;To;;[;
@O;0@T[[I"
class;T[[;[[:protected[[:private[[I"
instance;T[[;[[I"helpers;T@T[;[[;[[[I"ActiveSupport::Concern;To;;[;
@O;0@T[U:RDoc::Context::Section[i0o;;[;
0;0[@OI"ActionController;TcRDoc::NormalModule