0

I'm passing down some variables to a partial. model variable prints out just fine. But I cannot seem to add any other variables. I've tried it a few different ways.

  <%= render partial: 'layouts/modals/header', locals: {title: t('layouts.issue'), b: "b", modal: "issue_modal"} %>

Also tried it as

<%= render 'layouts/modals/header', title: t('layouts.issue'), b: "b" , modal: "issue_modal" %>

in header partial

<div class="row mx-0">
  <div class="modal-header w-100 row mx-0 justify-content-between p-t">
    <button id="create-back" class="btn btn-lg float-left text-rocket-grey-light text-uppercase" data-modal="<%= modal %>" type="button" name="button"><%= t('buttons.cancel') %></button>


    <button id="create-submit" class="btn btn-lg float-right btn-danger bg-rocket-red text-rocket-black" data-modal="<%= modal %>" type="button" name="button"><%= t('layouts.create') %></button>

    <%= b %>
    <%= modal %>
  </div>

  <div class="modal-title w-100 pl-3">
    <div class="text-danger m-t m-l text-uppercase font-weight-bold">
      <%= t('layouts.create') %> <%= title %>
    </div>
  </div>
</div>

no matter what I keep getting undefined local variable or method `b' for #<#<Class:0x00007fa3a43661c8>:0x00007fa3a53a2320> It doesn't make any sense to me that model and title print out fine but "b" is undefined. Ultimately I am trying to pass in a form builder object so I can put form.submit in my _header partial

Raj Singh
  • 163
  • 1
  • 9
  • "Undefined variable" what? Can you include the *exact* error you're getting? – tadman Sep 14 '20 at 23:07
  • @tadman undefined local variable or method `b' for #<#:0x00007fa3aba8cc70> – Raj Singh Sep 14 '20 at 23:11
  • ```<%= render (partial: 'layouts/modals/header', locals: {title: t('layouts.issue'), b: 'b', modal: "issue_modal"}) %>``` produces the same error – Raj Singh Sep 14 '20 at 23:12
  • Are you sure it's caused by that call and not another where the `locals` are not defined? – tadman Sep 15 '20 at 01:19
  • 1
    @tadman this is incorrect. Rails will assume that you are rendering a partial when you call `render` from the view. See https://guides.rubyonrails.org/layouts_and_rendering.html#using-partials – max Sep 15 '20 at 11:13
  • @max Thanks for pointing that out. I must be remembering the old behaviour, but I always use `partial` to be clear. – tadman Sep 15 '20 at 18:57

0 Answers0