-
Notifications
You must be signed in to change notification settings - Fork 19
Need caching : aka why is ransack_ui slow?
steveyken edited this page Dec 20, 2012
·
1 revision
Due to a bug further upstream in ransack, the form can take over 2 seconds to render. That's not acceptable for production systems. Until this bug (https://github.com/ernie/ransack/issues/154) is resolved, we solve the issue by using the cache_digests gem. (Note this is ruby 1.9 only)
Install the cache_digests gem and then wrap the form code in the following cache block. Note: this will ensure the cache keys are unique per controller.
<% cache [params[:controller], params[:q]] do %>
<%= ransack_ui_search :remote => true %>
<% end %>
If you need even more granularity you can add the params[:action] to the cache_key like so:
<% cache [params[:controller], params[:action], params[:q]] do %>
<%= ransack_ui_search :remote => true %>
<% end %>