Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8204771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:59:38+00:00 2026-06-07T07:59:38+00:00

I am passing two locals from a view ERB to a partial. Both locals

  • 0

I am passing two locals from a view ERB to a partial. Both locals are successfully passed in local_assigns. However, I am only able to use the FormBuilder via a local variable name in the partial. The other value is usable within my partial as local_assigns[:disable_edits], but not as disable_edits.

_form.html.erb

    <div>
    <%= f.fields_for :panels do |builder| %>
        <%= render "panel_fields", :f => builder, :disable_edits => true %>
    <% end %>
</div>

_panel_fields.html.erb

<div>
<p>
    <%= local_assigns[:disable_edits] %>
</p>
<p>
    <%#= disable_edits ? 'disable edits true' : 'disable edits false' %>
</p>
<p>
    <%= local_assigns.keys %>
</p>

local_assigns[:disable_edits] results in “true” being displayed.

local_assigns.keys results in “[:f, :disable_edits, :panel_fields]” being displayed.

Uncommenting the ternary statement results in “undefined local variable or method `disable_edits’ for #<#:0x4d58768>”

I am following what I understand is the latest suggested Rails syntax, but have tried manipulations using :partial=>, :locals=>, :as=>, etc. to no avail. I also do not think I’ve made this an optional argument in any way, so a lot of the information about testing with has_key vs. nil? isn’t helping me. My understanding is everything in local_assigns should be exposed as in the partial as a local variable with the same name as the hash key.

I’m getting by for now using local_assigns[:disable_edits], but would like to understand what is happening and correct things so I can use more conventional syntax. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:59:42+00:00Added an answer on June 7, 2026 at 7:59 am

    try using

    render :partial => "panel_fields", :locals => {:f => builder, :disable_edits => true }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Passing only two variables between controller and view - best practice? There
How do I go about passing two sets of Data to a view in
I'm trying to glue together two web services by passing a value from one
I am having an issue passing a :locals variable to two levels of views.
Parameter passing techniques: From what I can gather on these two techniques. Call By
From my controller I am passing two instance variables @events = Event.all and @images
i am passing two strings from a c file to asm file as parameters.
I'm passing two strings between two activities and for some reason, it crashes when
I'm passing two strings between two activities and for some strange reason, the strings
I have this code below. As you can see I am passing two variables

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.