bullet-train-co/nice_partials

Full view context not available within in-partial helpers?

Closed this issue · 2 comments

Here's the code I've got:

<% yield p = np %>

<% p.helpers do
  def account_controller_name_with_namespace
    params[:controller].gsub(/^account\//, '')
  end
end %>

<%
# don't add controller-specific actions in this file. instead, include them right below where this partial is
# included. see `app/views/account/teams/_breadcrumbs.html.erb` for an example.
%>

<% if p.account_controller_name_with_namespace == only_for %>
  <% if action_name == 'edit' %>
    <li class="breadcrumb-item"><%= ot("#{p.account_controller_name_with_namespace}.breadcrumbs.edit") || t('breadcrumbs.actions.edit') %></li>
  <% elsif action_name == 'new' %>
    <li class="breadcrumb-item"><%= ot("#{p.account_controller_name_with_namespace}.breadcrumbs.new") || t('breadcrumbs.actions.new') %></li>
  <% end %>
<% end %>

Error is:

Screen Shot 2020-12-07 at 11 00 26 PM

It works if I reference @view_context directly, e.g. @view_context.params.

I suppose this is where delegate_missing_to could come in?