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

  • Home
  • SEARCH
  • 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 6724889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:44:33+00:00 2026-05-26T09:44:33+00:00

Migrating app from php. and have this in the view: <%=render :partial => jt-test,

  • 0

Migrating app from php. and have this in the view:

<%=render :partial => "jt-test", :locals => {:info => "here is my info", :hide_location=>true} %>
<br /><br />
<%=render :partial => "jt-test", :locals => {:info => "here is my info"} %>

in _jt-test.html.erb:

My info:<br /> 
<%=info %>

<% if local_assigns.has_key? :hide_location %>
    you want to hide location!
<% end %>

Is the local_assigns the proper / best way to do this? Can I have an unlimited number of local_assigns? Is there a local_assigns for the main view called from the controller?

thx

  • 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-05-26T09:44:34+00:00Added an answer on May 26, 2026 at 9:44 am

    In the main view you’d just use normal action class variables (@whatever_variable_name), and they’re assigned in the controller:

    class FoosController
      def index
        @foos = Foo.all
      end
    end
    
    # template
    <% @foos.each |foo| %>
        <%= foo.name %>
    

    You may have unlimited locals in a partial, but if there are a “lot”, you might be doing it wrong. consider using an encapsulating object, breaking up the template more, etc.

    Rails exposes local variables to partials by their name (info and hide_location in your case). You don’t need to look it up using has_key?. See the passing local variables docs in the layout and rendering guide.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that I am migrating from Ruby to JRuby (due to
I'm migrating my app from the cell-based NSOutlineView to the view-based one. I'm mostly
Migrating a project from ASP.NET 1.1 to ASP.NET 2.0 and I keep hitting this
So, we are migrating an old web app from a 32-bit server to a
I'm creating a test application with Yii and have created my first migration. <?php
I have an AppEngine app that I'm migrating to run in Django, using app-engine-patch
I'm currently migrating a working app from CakePHP 1.2 to 1.3. Most things seem
I'm migrating a old (circa 2001) PHP 3 app to a new PHP5 server.
I'm migrating a web app from an IIS 6 server to an IIS 7
I am in progress of migrating an app from CakePHP 1.3 to 2.0, and

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.