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 4381238
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:37:26+00:00 2026-05-21T12:37:26+00:00

Maybe I missed something in http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials It seems that to render a partial, we

  • 0

Maybe I missed something in http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials

It seems that to render a partial, we can use

render 'shared/score'

but the next section talks about locals

render :partial => 'bar', :locals => { :score => @foo.score }

But what about the first form?

render 'shared/score', :locals => { :score => @foo.score }

The line above will not pass in the locals, why?

It seems like it has to be

render :partial => 'shared/score', :locals => { :score => @foo.score }

but why is that? (I am using Rails 3.0.6)

  • 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-21T12:37:27+00:00Added an answer on May 21, 2026 at 12:37 pm

    You actually want:

    render 'shared/score', { :score => @foo.score }
    

    Explanation

    You can look at this for their source code on render.

    http://api.rubyonrails.org/classes/ActionView/Rendering.html#method-i-render

    If you see that if the first parameter is NOT a hash, it will default to that being the name of the partial, and pass the second paramater as locals.

    The catch is that it wants the locals of in the 2nd paramater. :locals => {:score => @foo.score} may seem right at first, but you actually want: {:score=> @foo.score}.

    The reason for this is that it sets the :locals option for the _render_partial method to the second paramater. So if you were to do it your way, it would actually look like:

    :locals => {:locals => {:score=>@foo.score}}
    

    Which doesn’t make much sense.

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

Sidebar

Related Questions

I'm thinking maybe I missed something in JavaScript that I'm just picking up now.
I am browsing trough the CI documentation particularly http://codeigniter.com/user_guide/libraries/pagination.html . First thing that was
Maybe I missed something, but I cant figure out why Visual Studio 2008 isn't
I think I have missed something with the code below... Maybe you can help
Maybe I have missed something, but what are wrong with this regular expresion? var
Maybe I missed this in the upgrade documentation, but if I output Rails.root in
I'm very new to jQuery and javascript in general, so maybe there's something I've
I think I have run into a bug in Mojarra 2.1.0. Maybe I missed
I've read the guide about application data backup in Android here http://developer.android.com/guide/topics/data/backup.html , but
Something is wrong with my code. Chrome code spectrator say that there is probmel

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.