Les helpers Action View fournissent des méthodes de formatage propres pour le texte, les nombres, les dates et les ressources multimédias dans les vues.
Helpers pour les nombres et les devises
<%= number_to_currency(1234.56) %>
<!-- => "$1,234.56" -->
<%= number_to_currency(1234.56, unit: "€", format: "%u %n") %>
<!-- => "€ 1,234.56" -->
<%= number_to_percentage(85.4, precision: 1) %>
<!-- => "85.4%" -->
<%= number_to_human_size(15485863) %>
<!-- => "14.8 MB" -->
<%= number_with_delimiter(12345678) %>
<!-- => "12,345,678" -->
Helpers de dates et heures
<!-- Temps relatif lisible -->
<%= distance_of_time_in_words(Time.now, 3.hours.from_now) %>
<!-- => "about 3 hours" -->
<%= time_ago_in_words(user.created_at) %>
<!-- => "3 days ago" -->
<!-- Balise sémantique HTML5 <time> -->
<%= time_tag(article.published_at) %>
<!-- => '<time datetime="2026-10-25T00:00:00Z">October 25, 2026</time>' -->
Helpers de texte et de chaînes
<%= truncate("The quick brown fox jumps over the lazy dog", length: 20) %>
<!-- => "The quick brown f..." -->
<%= pluralize(3, "comment") %>
<!-- => "3 comments" -->
<%= pluralize(1, "comment") %>
<!-- => "1 comment" -->
<%= highlight("Text with keywords highlighted", "keywords") %>
<!-- => 'Text with <mark>keywords</mark> highlighted' -->
<%= simple_format("Paragraph 1
Paragraph 2") %>
<!-- => "<p>Paragraph 1</p><p>Paragraph 2</p>" -->
Helpers de balises et d'assets
<%= link_to "Profile", user_path(@user), class: "nav-link" %>
<%= button_to "Delete", user_path(@user), method: :delete, data: { turbo_confirm: "Are you sure?" } %>
<%= image_tag "avatar.png", alt: "User Avatar", size: "64x64" %>