Last active
January 20, 2016 15:28
-
-
Save the-undefined/b189ef5b8c14a1a3782f to your computer and use it in GitHub Desktop.
Presenter that yield to the view for route information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Presenter | |
include SortableColumns | |
def sortable_column_heading(text:, attr:, &block) | |
label = sort_link_text(text, attr) | |
link_params = sort_link_params(attr) | |
block.call(label, link_params) | |
end | |
private | |
attr_reader :view_context | |
def initialize(view_context: view_context) | |
@view_context = view_context | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table> | |
<thead> | |
<tr> | |
<th> | |
<% @presenter.sortable_column_heading( | |
text: 'First Name', | |
attr: 'first_name') do |label, sort_params| %> | |
<%= link_to label, sort_params %> | |
<% end %> | |
</th> | |
<th> | |
<% @presenter.sortable_column_heading( | |
text: 'Email', | |
attr: 'email') do |label, sort_params| %> | |
<%= link_to label, sort_params %> | |
<% end %> | |
</th> | |
</tr> | |
</thead> | |
<tbody> | |
... | |
</tbody> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment