Closed gap777 closed 1 year ago
Pass self
into the no_results_html
:
grid.no_results_html(self)
For posterity, I'll note that this appears to be something like a view context, and on it are all the helper methods I would expect and hope for:
def no_results_html(view_context)
view_context.link_to ....
end
Yes, it is. I just found there is another way:
class Grid
include Rails.application.routes.url_helper
def no_results_html
helpers = ApplicationController.helpers
helpers.content_tag(:div, "No Results") + helpers.link_to("Back", root_path)
end
end
Up to you....
https://stackoverflow.com/questions/4112050/how-to-use-all-view-and-helper-methods-inside-of-rails-console-for-rails-2-x-and https://stackoverflow.com/questions/2846247/rails-check-output-of-path-helper-from-console
By default, it seems that the table empty state must be a simple translated string:
We'd like to use richer HTML for the empty state, composed of images, links, etc, and generated by each table.
However, the
no_results_html
isn't being called from a view context (so we don't have access to helpers likelink_to
).How can we do this?