Torch v1.0.0-rc.3 Torch.TableView

Helpers for rendering Torch-generated tables.

Summary

Functions

Prettifies and associated model for display

Generates a sortable link for a table heading

Functions

table_assoc_display_name(model, field, options)

Prettifies and associated model for display.

Displays the model’s name or “None”, rather than the model’s ID.

Example

# If post.category_id was 1
table_assoc_display_name(post, :category_id, [{"Articles", 1}])
# => "Articles"

# If post.category_id was nil
table_assoc_display_name(post, :category_id, [{"Articles", 1}])
# => "None"
table_link(conn, text, field)

Generates a sortable link for a table heading.

Clicking on the link will trigger a sort on that field. Clicking again will reverse the sort.

Example

table_link(conn, "Name", :name)