Need help with show_for?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

465 Stars 50 Forks MIT License 267 Commits 0 Opened issues


Wrap your objects with a helper to easily show them

Services available


Need anything else?

Contributors list


Gem Version Code Climate

ShowFor allows you to quickly show a model information with I18n features.


Install the gem:

gem install show_for

Or add ShowFor to your Gemfile and bundle it up:

gem 'show_for'

Run the generator:

rails generate show_for:install

And you are ready to go.

Note: This branch aims Rails 5 and 6 support, so if you want to use it with older versions of Rails, check out the available branches.


ShowFor allows you to quickly show a model information with I18n features.

Will generate something like:

José Valim
Created at
13/12/2009 - 19h17
Etiam porttitor eros ut diam vestibulum et blandit lectus tempor. Donec venenatis fermentum nunc ac dignissim. Pellentesque volutpat eros quis enim mollis bibendum. Ut cursus sem ac sem accumsan nec porttitor felis luctus. Sed purus nunc, auctor vitae consectetur pharetra, tristique non nisi.

You can also show a list of attributes, useful if you don't need to change any configuration:

Value lookup

ShowFor uses the following sequence to get the attribute value:

  • use the output of a block argument if given
  • use the output of the
    argument if given
  • check if a
    method is defined
  • retrieve the attribute directly.


ShowFor handles a series of options. Those are:

  • :format - Sent to

    when the attribute is a date/time object.
  • :value - Can be used instead of block. If a

    is called as instance method.
  • :if_blank - An object to be used if the value is blank. Not escaped as well.

  • :separator - The piece of html that separates label and content, overriding the global configuration.

In addition, all containers (

) can have their html options configured through the
options. Containers can have their tags configured on demand as well through


ShowFor also exposes the label method. In case you want to use the default

lookup and the default wrapping:
a.label :name                  #=> Name
a.label "Name", id: "my_name"  #=> Name

Optionally, if you want to wrap the inner part of the label with some text (e.g. adding a semicolon), you can do so by specifying a proc for

that will be called with any label text. E.g.:
  ShowFor.label_proc = lambda { |l| l + ":" }

When taking this route, you can also skip on a per label basis by passing the

option with a value of false.


ShowFor also supports associations.


The first is a

association, which works like an attribute to ShowFor, except it will retrieve the artist association and try to find a proper method from
to be used. You can pass the option :using to tell (and not guess) which method from the association to use.

:tags is a

association which will return a collection. ShowFor can handle collections by default by wrapping them in list (
    with each item wrapped by an
  • ). However, it also allows you to give
    it you want to render them inline.

    You can also pass a block which expects an argument to association. In such cases, a wrapper for the collection is still created and the block just iterates over the collection objects.

    Here are some other examples of the many possibilites to custom the output content:



    • José Valim (
    • Carlos Antonio da Silva (


    • Jonas Grimfelt (

    Supported Ruby / Rails versions

    We intend to maintain support for all Ruby / Rails versions that haven't reached end-of-life.

    For more information about specific versions please check Ruby and Rails maintenance policies, and our test matrix.

    Bugs and Feedback

    If you discover any bugs or want to drop a line, feel free to create an issue on GitHub.

    MIT License. Copyright 2012-2019 Plataformatec.

  • We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.